views:

33

answers:

2

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", 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...

A: 

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 = "" }    
        );
Zote
A: 

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

Pandiya Chendur