Search code examples
asp.net-mvcasp.net-mvc-routing

ASP.NET MVC: Controlling naming conventions of controllers / views?


Can anyone tell me how i can manually edit my naming convention of my routes.. Let me explain. I am programming everything in english as per microsoft standards but i require

  www.mydomain.com/Reserva  (Spanish for reservation)

I actually have the following

ReservationController and then below views i have a folder called Reservation with a file called index.aspx (my view).

So basically i am happy with the naming convention i have but currently it necessary to browse to

  www.mydomain.com/Reservation

and not

  www.mydomain.com/Reserva 

to get my page to come up

I have the default MapRoute installed, what do i do to enable the above? any ideas?

   routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

Solution

  • You could just create a new route in that same file like so:

    routes.MapRoute(
                "Reserva",                                              // Route name
                "Reserva/{action}/{id}",                           // URL with parameters
                new { controller = "Reservation", action = "Index", id = "" }  // Parameter defaults
            );
    

    and put it in your file above the default route.