2013-07-12 86 views
0

我在ASP得到了與routin問題MVC應用程序:The resource cannot be found.ASP MVC路由的行爲

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) 

做工精細

回答

4

更改您的ActionLink的匹配動作名稱:

@Html.ActionLink((string)fullName, "UpdateUser", "Users", new { userId = user.Id }, null) 
+1

Ohhhhh。謝謝:)))工作4小時...需要休息。 –

+0

很高興幫助;-) –

0

從的NuGet安裝T4MVC和避免這些錯誤,你將有你的智慧控制器和行動! 我知道這是硬編碼控制器和動作名稱的頭痛。

您與t4mvc代碼:

@Html.ActionLink((string)fullName, MVC.Users.UpdateUser(), new { userId = user.Id }, null); 

試試看吧。