【发布时间】:2017-06-21 11:01:35
【问题描述】:
我正在开发 MVC 4 应用程序并希望通过消息重定向回调用操作视图:
- 调用的操作:上传
- 当前视图:索引
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" />
}
谢谢!
【问题讨论】:
-
使用
return RedirectToAction(...)进行重定向,并将消息作为查询字符串值传递或放入Tempdata并在GET方法中检索
标签: c# asp.net-mvc