The ASP.NET Core project structure is different from that of ASP.NET Web Forms & ASP.NET MVC project structure.
This is a default project structure while creating an empty ASP.NET Core application in Visual Studio.
ASP.NET Core Project Structure
- wwwroot
- Program.cs
- Startup.cs
By default, the wwwroot folder in the ASP.NET Core project is treated as a root folder. Static files can be stored in any folder under the wwwroot and accessed with a relative path to that root.
Proram.cs file contains the Main() method, which is the entry point for our application.
The Main() method calls method expression BuildWebHost() to build web host with pre-configured defaults.
Startup.cs is like Global.asax of traditional asp.net web forms application. It is executed first when the application starts.
The startup class can be configured using UseStartup<T>()
method.
Filename: Program.cs
namespace MyFirstCoreApp { public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); } }