This post is a continuation of my previous articles on ASP.NET Core. Please read them here:
Before I start with Startup class, I would like to give you an idea about DNX, or may be just refresh it if you already know!
What is DNX? How does it work?
The .NET Execution Environment (DNX) is a software development kit (SDK) and runtime environment that has everything you need to build and run .NET applications for Windows, Mac and Linux. It provides a host process, CLR hosting logic and managed entry point discovery. DNX was built for running cross-platform ASP.NET Web applications, but it can run other types of .NET applications, too, such as cross-platform console apps. It works right from your command line tool.
(source: docs.asp.net)
Here's a brief expo of where we are:

Okay, let's understand the basic of the Startup class:
What is Startup.cs file? What role dos it play in ASP.NET Core project?
The Startup class is an enhanced way to boot up your app, and dependency injection is now an integral part of ASP.NET. The global.asax file is not available ASP.NET 5. In earlier versions of ASP.NET, the System.Web assembly took care of starting the app, and the global.asax file had methods (Application_Start / Application_End etc.) that were called by System.Web in which you could provide custom logic. The steps needed to start up an application are now determined by you using the Startup class. The Startup class contains a Main method. That's the entry point for the application.
When the DNX executes the application, it looks for this method and calls it just like earlier versions of .NET. Almost all .NET applications boot using the Main method. The implementation of the Main method here tells the Web Application to run using the Startup class. That's, in fact, the class the Main method is in. And it passes in any command line arguments. The Startup class is just a simple class not deriving from another class or implementing an interface. The DNX hosting environment will by convention call two methods: ConfigureServices and Configure.






Pradeep SinghPosted Oct 4, 2018, 5:15 AM
How control comes to configureservice and configure method. What is the flow after leaving constructor of startup class.
Sudhanshu ShekharPosted Aug 11, 2018, 1:15 PM
The article is nicely written and it is easy to understand. Just wanted to add that the Main method is in the Program.cs file and the Asp .net core's WebHost invokes the Startup file followed by calling the ConfigureServices and Configure menthod.
pravin wadePosted Jul 30, 2018, 2:27 AM
Also, what is the entry point for "Startup.cs" - when it will get triggered?
pravin wadePosted Jul 30, 2018, 2:26 AM
Hi there, I have mvc5 and can see the global.aspx. Please explain me
DavidPosted Oct 14, 2017, 12:43 PM
This is the first article I've read from you and I have to say it is really easy to understand for a beginner. I will keep looking at your articles from now on. By any chance have you published any .NET books ?
Michael GriffithsPosted Apr 10, 2016, 10:14 AM
Nice share
Vivek KumarPosted Apr 8, 2016, 1:35 PM
Nice one...
Vignesh ManiPosted Apr 5, 2016, 8:29 AM
Nice one
Humayun Kabir MamunPosted Apr 4, 2016, 4:52 AM
Nice...
Debasis SahaPosted Apr 4, 2016, 4:06 AM
Good One..
Manoj KulkarniPosted Apr 3, 2016, 10:56 PM
Nice article. Thank you for sharing
S.Ravi KumarPosted Apr 3, 2016, 9:39 AM
Very Informative Article.
ravi chaitanyaPosted Apr 3, 2016, 5:52 AM
Hi how to setup centralized exception handling in asp.net core
Ammar ShaukatPosted Apr 2, 2016, 3:02 PM
helping..
Rahul Kumar SaxenaPosted Apr 2, 2016, 12:38 PM
Good One.