开发者

Url routing issue in asp.net mvc

I am doing a return RedirectToAction("Index", "Clients"); from my home controller.... It is fine but my url looks like http://localhost:1115/Clients/Index... How to remove index from url in asp.net mvc? Any suggestion....

My routes,

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Registrations",                                             
            "{controller}/{action}/{id}",                           
            new { controller = "Registration"开发者_StackOverflow中文版, action = "Create", id = "" }    
        );
        routes.MapRoute(
            "Clients",                                              
            "Clients/{action}/{id}",                           
            new { controller = "Clients", action = "Index", id = "" }  
        );
    }

But still it doesn't seem to remove index from my url...


You can change your default action to Index or create an new route like

routes.MapRoute(
            "Clients",                                             
            "Clients/{action}/{id}",                           
            new { controller = "Clients", action = "Index", id = "" }    
        );


I got it working by just pushing my default route to the bottom as stated in one of the answers for asp.net-mvc default route

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜