How to match example.com/root/login URL with example.com/login example?

Possible duplicate:
How to match Home / Action / id with action / id?

I have a Views folder called "root" Inside, this is a view called "login.aspx".

enter image description here

I have a controller called "rootController.cs".

enter image description here

I have an ActionResult called login () It returns View ("login").

When I launch my application ... To go to the login page, I have to see the ugly URL www.example.com/root/login

enter image description here

I would like him to say www.example.com/login.

How can I do it?

Thanks in advance!

EDIT: ////

Still:

enter image description here

EDIT: ////

It is decided:

enter image description here

+4
source share
1 answer

Go to the MvcApplication class (by default it is in the Global.asax.cs file) and add the following code to the RegisterRoutes(RouteCollection routes) function:

 routes.MapRoute( "Login", // Route name "login", // URL with parameters new { controller = "root", action = "login" } // Parameter defaults ); 
+2
source

Source: https://habr.com/ru/post/1440420/


All Articles