我對MVC 4應用程序的工作,並希望重定向回來的消息調用操作觀點:重定向回來了文件後,郵件上傳MVC 4 C#
- 行動,呼籲:上傳
- 當前視圖:指數
public class HospitalController: Controller {
public ActionResult Index()
{
return View(Model);
}
[HttpPost]
public ActionResult Index(Model model)
{
return View(ohosDetailFinal);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Upload(HttpPostedFileBase upload,FormCollection form)
{
//Here i want to pass messge after file upload and redirect to index view with message
// return View(); not working
}
}
@using (Html.BeginForm("Upload", "Hospital", null, FormMethod.Post, new { enctype = "multipart/form-data", @class = "" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<input type="file" id="dataFile" name="upload" class="hidden" />
}
謝謝!
使用'返回RedirectToAction(...)'重定向,並通過消息作爲查詢字符串值,或把它放在'Tempdata'和檢索它在GET方法中 –