Advertise with us

How can I set a route for a controller without a default action in MVC 5?

I have the following:

routes.MapRoute(

    "Account",
     url: "{controller}/{action}/{id}",
     defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
    );

However I don't want to specify a default action. Is there a way to do this for my MVC5 application?

Last updated:9/28/2013 7:01:40 AM

1 Answers

Ankita Pandey
Ankita Pandey

Hey Ashish!

You can try the below code.
routes.MapRoute(

    "Account",
     url: "Account/{action}/{id}",
     defaults: new { controller = "Account", id = UrlParameter.Optional }
    );

Last updated:9/28/2013 7:01:40 AM

Answer