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)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                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.

Related Articles

Related Questions

Is the 2025 CKA Exam Really Harder?

I've been studying for the Certified Kubernetes Administrator (CKA) exam since September 2024, and I feel like I've put in a lot of effort....

Has Anyone Ever Experienced “Programmer’s Block”?

I've been coding on and off since the 90s and have a degree in it, but my day job isn't programming. Lately, I've been...

Is KodeCloud a Good Resource for Learning DevOps?

I've been exploring some DevOps tasks at work recently and I'm curious about whether KodeCloud is a reliable resource for diving into tools like...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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

Latest Tools

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions