I am using MVC to upload some files. The following code works fine but I would like to be return some information from the server ( eg a message or an ID ). What I am trying to do is very simple but I fear I amy not have made it clear. Can anyone help please?
VIEW
@using (Html.BeginForm("AddFileX", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" })) { <input type="file" name="files" multiple="true" /> <input id="submit" type="submit" value="Upload" /> } CONTROLLER
[HttpPost] public ActionResult AddFileX(IEnumerable<HttpPostedFileBase> files) { foreach (var file in files) { if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), fileName); file.SaveAs(path); } } // I would like to return a message or an ID of something // (eg "you are about to overwrite your files" or the ID of something not shown here) return View("IdxUpload"); // This line probably needs to be changed }