This is the action method where I save user input and then redirect to the view mode:
[HttpPost]
public ActionResult SaveDocumentCitizen(DocumentCitizen documentCitizen)
{
DocumentCitizenRepository repository = new DocumentCitizenRepository();
repository.SaveDocument(documentCitizen);
return RedirectToAction(actionName: "ViewDocumentCitizen", routeValues: new RouteValueDictionary(documentCitizen));
}
And here's the ViewDocumentCitizen action method:
public ActionResult ViewDocumentCitizen(DocumentCitizen doc)// The Attachment value is null here
{
DocumentCitizenRepository repository = new DocumentCitizenRepository();
DocumentCitizen docCitizen = repository.UpdateTextualValues(doc.DocID);
return View(viewName: "DocumentCitizen", model: docCitizen);
}
The DocumentCitizen model has the following property:
public byte[] Attachment{get;set;}
I choose a file then submit the form and then when I debug the SaveDocumentCitizen
method I can see that the Attachment is not null. But it gets set to null as soon as it's passed to the ViewDocumentCitizen
method. What do I have to do to have the file property value persisted through redirection?