ActionLink not generating correct url
ASP.NET MVC3/Razor
I am having problems getting the HtmlActionLink to pick the correct route (the second below).
Here are al开发者_JS百科l my routes:
routes.MapRoute("LoginPage", "login", new { controller = "login", action = "index" });
routes.MapRoute("HomePage", "pages/{client}/{matter}", new { controller = "home", action = "index", client = UrlParameter.Optional, matter = UrlParameter.Optional });
routes.MapRoute("Default", "{controller}/{action}", new { controller = "default", action = "index" });
Here is the action link:
Html.ActionLink("user name", "index", "home", new RouteValueDictionary(new { client="abcdef" }), null)
I end up with this:
http://domain/home?client="abcdef"
Anyone know whit it is not matching the second route? Or a way to debug it
Oddly enough, what you pasted works for me :), meaning I got second route picked and proper link. Do you have any other routes, or only those three? I got your result when I removed matter = UrlParameter.Optional (sure you were recompiling project while you were experimenting ;-).
精彩评论