Timmer Timmer - 1 year ago 97
ASP.NET (C#) Question

MVC model not saving the value

var ticketnumber = TempData["ticketId"] as Ticket;
ticketnumber.TicketId = model.TicketId;
HttpPostedFileBase file = Request.Files["ImageData"];
UploadRepository service = new UploadRepository();
int i = service.UploadImageInDataBase(file, model);

I have the value inside my tempdata but when i try to assign the value of it to the model value it doesnt save and even in debug it tells me the value hasnt changed so i just dont get what i am doing wrong.

Answer Source

You need to change the assignment:


ticketnumber.TicketId = model.TicketId;


model.TicketId = ticketnumber.TicketId;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download