Timmer Timmer - 4 months ago 19
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.


You need to change the assignment:


ticketnumber.TicketId = model.TicketId;


model.TicketId = ticketnumber.TicketId;