Where is the default page in mvc3 located?

I'm not sure how a domain can load a test when there is no default document such as default.aspx in the root. Is there in "global.asax"? where is the default page in mvc3?

+4
source share
3 answers

You will find it in Views / Home /

Index page

Mvc works through the controller model - model - model

When you create a project by default, you will find that global.asax has the following code:

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

This means that the default page is the index action in the Home controller.

In this example, you can access other pages: If you have an AccountController with the "Login" view, this means that you can access the login page by going to / Account / Login.

+10
source

By default, the default page is displayed using the controller index action. Html is located in /Views/Home/index.cshtml.

This is configured in Global.asax in the RegisterRoutes method.

+2
source

Also, what Lauw already talked about.

If you use basic forms authentication and want a different page by default than Home, you can change the redirects inside the AccountController, for example. the change

  public ActionResult LogOff() { FormsAuthentication.SignOut(); return RedirectToAction("Index", "Home"); } 

to something like

  public ActionResult LogOff() { FormsAuthentication.SignOut(); return RedirectToAction("LogOn", "Account"); } 

The same goes for LogOn and Register. If you do not, you will accidentally be taken to the old home page.

0
source

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


All Articles