我在asp mvc应用程序中遇到了例程问题:The resource cannot be found.
Requested URL: /Admin/Users/Update
我的操作代码是:
[HttpGet]
public ActionResult UpdateUser(int userId)
{
-some code-
return View();
}
ActionLink是:
@Html.ActionLink((string)fullName, "Update", "Users", new { userId = user.Id }, null)
路线:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/",
new { controller = "Units", action = "Units" },
new [] {"RSystem.Areas.Admin.Controllers"}
);
}
但是其他行动,例如
public ActionResult Users(Role? role)
工作正常
答案 0 :(得分:4)
更改ActionLink以匹配操作名称:
@Html.ActionLink((string)fullName, "UpdateUser", "Users", new { userId = user.Id }, null)
答案 1 :(得分:0)
由于您的ActionResult方法名称是UpdateUser,因此在ActionLink中您必须像这样传递
@Html.ActionLink((string)fullName, "UpdateUser", "Users", new { userId = user.Id }, null)