开发者

ActionLink not generating correct url

开发者 https://www.devze.com 2023-03-11 12:51 出处:网络
ASP.NET MVC3/Razor I am having problems getting the HtmlActionLink to pick the correct route (the second below).

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 ;-).

0

精彩评论

暂无评论...
验证码 换一张
取 消