我看了很多帖子,我没有看到mystake。路线MVC问题
可以请一些身体帮助我。
有我的Global.asax
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute("UserName", "Account/{action}/{username}",
new { action = "EditProfile", controller = "Account" });
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
当我使用
<%= Html.ActionLink("Edit Account", "EditProfile", "Account", new { username = Html.Encode(Page.User.Identity.Name) },null) %>
我得到这个网址
http://localhost:8458/Account/EditProfile?username=cboivin
,如果我尝试直接调用URL像 http://localhost:8458/Account/EditProfile/cboivin
没有工作......
有我的方法,我的AccountController
public ActionResult EditProfile(string username)
{
return View(ServiceFactory.UserAccount.GetUserByUserName(new GetUserByUserNameArgs(username)));
}
我不知道哪里是我的错误。有些身体可以帮助我吗?谢谢。