【发布时间】:2014-03-28 22:07:04
【问题描述】:
我有一个返回错误视图的控制器方法。我拥有的视图与控制器方法“AssignTask.cshtml”同名。方法为“public virtual ActionResult AssignTask(ManageTaskModel model)”
谁能看出我做错了什么?
[HttpGet]
public virtual ActionResult ManageTasks()
{
try
{
var model = new ManageTaskModel ();
model.assignedPSUsers = Orchestrator.GetAssignedPSUsers();
return View(model);
}
catch (Exception e)
{
ModelState.AddModelError("ErrorMsg", e.Message);
};
return this.RedirectToAction("Index");
}
[HttpPost]
public virtual ActionResult ManageTasks(ManageTaskModel model)
{
if (!ModelState.IsValid)
{
return View(model);
}
try
{ //User has seleced the user that they want to see Tasks for
if (model.selectedUser != null && model.newUser==null)
{
model.assignedPSUsers = Orchestrator.GetAssignedPSUsers();
model.FcvsTaskList = Orchestrator.GetTasksForAssignedPSUser(model.selectedUser);
return AssignTask(model);
}
}
catch (Exception e)
{
ModelState.AddModelError("ErrorMsg", e.Message);
return View(model);
}
return this.RedirectToAction("Index");
}
[HttpGet]
public virtual ActionResult AssignTask(ManageTaskModel model)
{
if (model.selectedUser != null && model.newUser == null)
{
**return View(model);** //returning the ManageTask instead of AssignTask View
}
return this.RedirectToAction("Index");
}
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4