How to set default page asp.net

How to set default page asp.net [duplicate]

ASP.NET WebForms

On the web.config file, try this to use the clear tag before:

<system.webServer>
  <defaultDocument>
    <files>
      <clear />
      <add value="Pages/Home.aspx" />
    </files>
  </defaultDocument>
</system.webServer>

Take a look here: http://www.iis.net/configreference/system.webserver/defaultdocument

ASP.NET MVC / ASP.NET CORE

Depending of the version of asp.net mvc you are using, you can have it on a different file (~/Global.asax.cs in v3 or older or ~/App_Start/RouteConfig.cs in v4 or newer). In both cases, you will see something register the routes, because asp.net mvc uses routes instead files like webforms. So, you can change the default values:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new 
        { 
            controller = "Home", // default controller
            action = "Index",  // default action on the controller
            id = UrlParameter.Optional
        }
    );
}

It is similar on the ASP.NET CORE.

Take a look here: http://www.codeproject.com/Articles/624181/Routing-Basics-in-ASP-NET-MVC

 

 

 

posted @ 2020-04-17 15:25  ChuckLu  阅读(193)  评论(0编辑  收藏  举报