how to define routes in MVC

Asked

Viewed 21 times

0

good night..

I have the following Controller: Homcontroller

with Action: Login

By clicking the enter button my URL is as follows:

http://localhost:58379/home/login

I would like the URL not to be presented that way, and yes:

http://localhost:58379/Welcome

I tried to reconfigure the route, but all my attempts failed:

        routes.MapMvcAttributeRoutes();

        routes.MapRoute(
            "T",
            "bemvindo",
            new { controller = "Home", action = "Login" }
        );

where is my error in this configuration?

i need to set the Rote attribute in my Controller/Action?

thank you!

  • you can use Route to pass the name you want to your action, but to remove your controller name look at this answer here, and see if it fits.

  • Have you tried to put [Route("Welcome")] just above your Login action in Home controller?

  • yes. had already tried to put [Route("Welcome")]

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.