开发者

ASP.Net MVC Routing URL Generation

开发者 https://www.devze.com 2022-12-20 21:20 出处:网络
Html.ActionLink appends \"Index\", the action name to the end of the urls, but i would like to not have the index action listed in the default controller url (hope that makes some sense...)

Html.ActionLink appends "Index", the action name to the end of the urls, but i would like to not have the index action listed in the default controller url (hope that makes some sense...)

Not Wanted: /ControllerName/Index WANTED: /ControllerName

Below is my routing setup:

            routes.MapRoute(
                null,
                "{controller}/{action}/{id}",
                null,
                new { id = @"\d+" }
            );

            routes.MapRoute(
                null,
                "{controller}/{action}"
            );

            routes.MapRoute(
                null,
                "{controller}",
                new { action = "Index" }
            );

            r开发者_开发问答outes.MapRoute(
                null,
                "",
                new { controller = "Home", action = "Index" }
            );


Flip them all around. The routes, as you've listed them, should be in the reverse order you've listed them in.

0

精彩评论

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