bigopon bigopon - 1 year ago 77
ASP.NET (C#) Question

.NET MVC 4.5 rewrite index route

Currently I have a controller like this:

class AccountController : Controller {

public ActionResult Index() {
return View();

It's ok except one part that user when go to this page will have this url:
, which is unwanted. How can I have
only ?

Answer Source

Something like this could do the trick

    name: "Account",
    url: "account/{action}/{id}",
    defaults: new { controller = "Account", action = "Index", id = UrlParameter.Optional }

It could be also done with Attribute routing decorating with [Route] the method you want to be the default.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download