我读了很多帖子,但我没有看到我的赌注。
一些身体可以帮助我吗?
有我的 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
如果我尝试像 http://localhost:8458/Account/EditProfile/cboivin一样直接调用 url
不工作...
我的 AccountController 中有我的方法
public ActionResult EditProfile(string username)
{
return View(ServiceFactory.UserAccount.GetUserByUserName(new GetUserByUserNameArgs(username)));
}
我不知道我的错误在哪里。一些身体可以帮助我吗?谢谢。