1

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

2 Answers 2

0

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 = "" }    
        );
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.