Home > DeveloperSection > Forums > How can I set a route for a controller without a default action in MVC 5?
Ashish Pandey

Total Post:128

Points:898
Posted on    September-28-2013 4:09 AM

 ASP.NET MVC ASP.NET MVC 
Ratings:


 1 Reply(s)
 1079  View(s)
Rate this:
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?



Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    September-28-2013 7:01 AM

Hey Ashish!

You can try the below code.

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

Don't want to miss updates? Please click the below button!

Follow MindStick