I have a controller named login and a view of the same name. When I access the login page, the URL is displayed like this: ~/Login/Login
You can customize this route so that the link looks like this: ~/Login
?
I have a controller named login and a view of the same name. When I access the login page, the URL is displayed like this: ~/Login/Login
You can customize this route so that the link looks like this: ~/Login
?
In this controller Login
is there any Action
? Take a look at your Global.asax and see how the default route looks like this:
IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Padrão
"{controller}/{action}/{id}", // Parametros da URL
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
But in this you can put it like this:
new { controller = "Login", action = "NomeDaActionDentroDaControllerLogin", id = UrlParameter.Optional }
Along with everything, this way:
"Default", // Padrão
"{controller}/{action}/{id}", // Parametros da URL
new { controller = "Login", action = "NomeDaActionDentroDaControllerLogin", id = UrlParameter.Optional }
It's okay to have a View
as the same name as Controller , but see how the default route in this > Global.asax . And put it the way I put it here, and also check how this route is being called for example, if you are via localhost, it should appear as standard on the route:
http://localhost:2020/Controller/Action/Id=?....!
If any Action within LoginController in your project, calling is View Login
with the same name, in the URL it should only be called so
http://localhost:2020/Controller/Action/
Action is called, Action . Then Action will render to View
you've created within it!