lea*_*ing 12 asp.net-mvc asp.net-mvc-3
下面,在CreateTest中,uponsuccessful,我想从CreateTest重定向到Tests.
我想做类似以下的事情:
public ActionResult Tests(int ID, string projectName)
{
TestModel model = new TestModel (ID, projectName);
return View(model);
}
[HttpPost]
public ActionResult CreateTest(TestModel model)
{
try
{
return RedirectToAction("Tests");
}
catch (Exception e)
{
ModelState.AddModelError("Error", e.Message);
return View(model);
}
}
Run Code Online (Sandbox Code Playgroud)
Dar*_*rov 32
您可能需要在重定向时提供参数:
return RedirectToAction("Tests", new {
ID = model.ID,
projectName = model.ProjectName
});
Run Code Online (Sandbox Code Playgroud)
您将重定向到的URL现在看起来像这样:
/Foo/Tests?ID=123&projectName=abc
归档时间: |
|
查看次数: |
60098 次 |
最近记录: |