Most of us may have worked upon various versions of ASP.NET, and a few of you must be aware of the major changes that happened in the application initialization and configuration phase. In this article, I'll be outlining a few of those major changes starting from ASP.NET MVC, ASP.NET Core 1.x, and ASP.NET 2.x.
In ASP.NET
In the era of ASP.NET (prior to ASP.NET Core releases), the loading of the application was handled by IIS. Inetmgr used to call the web application's entry point, whereas Global.asax.cs used to provide the Application_Start() method. The below sample code snippet is taken from Global.asax.cx file.
In the era of ASP.NET (prior to ASP.NET Core releases), the loading of the application was handled by IIS. Inetmgr used to call the web application's entry point, whereas Global.asax.cs used to provide the Application_Start() method. The below sample code snippet is taken from Global.asax.cx file.
- public class MvcApplication : System.Web.HttpApplication
- {
- protected void Application_Start()
- {
- AreaRegistration.RegisterAllAreas();
- FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
- RouteConfig.RegisterRoutes(RouteTable.Routes);
- BundleConfig.RegisterBundles(BundleTable.Bundles);
- }
- }
In ASP.NET Core 1.x
Moving on to ASP.NET Core, Global.asax.cs doesn't exist anymore as the application initialization process itself has changed a lot. In the case of Core, almost all the application initialization and configuration related changes are taken care of by two important files named Program.cs and Startup.cs.
Moving on to ASP.NET Core, Global.asax.cs doesn't exist anymore as the application initialization process itself has changed a lot. In the case of Core, almost all the application initialization and configuration related changes are taken care of by two important files named Program.cs and Startup.cs.
Program.cs
This file takes care of the web hosting part. Below is the sample code snippet.
This file takes care of the web hosting part. Below is the sample code snippet.
- public class Program
- {
- public static void Main(string[] args)
- {
- var host = new WebHostBuilder()
- .UseKestrel()
- .UseContentRoot(Directory.GetCurrentDirectory())
- .UseIISIntegration()
- .UseStartup<Startup>()
- .Build();
- host.Run();
- }
- }
Startup.cs
This file takes care of dependency injection and configuration related things. Below is the sample code snippet.
This file takes care of dependency injection and configuration related things. Below is the sample code snippet.

karthik shankarPosted Jul 16, 2019, 12:04 AM
Very helpful ,Thank you
Tridip BhattacharjeePosted Feb 15, 2018, 7:06 AM
Nice write up. thanks