How To Set Default Home Page For ASP.NET Razor

This can be done in the RouteConfig.cs. You can set the default route that will be used to display the home page. You can find this file in Project->App_Start->RouteConfig.cs. The config inside this file will let you set default home page for ASP.NET razor MVC websites. The contents of the default file should look something like this.

        public static void RegisterRoutes(RouteCollection routes)

                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

The line that you need in particular to change the default homepage of an ASP MVC site is the defaults section. Change the name of the controller to whatever you want. The action for this will be the name of the method that you want to call within that controller. Once you have added this information your server should now be displaying this page as the default home page for your site.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.