If we had created a new blank project (EMPTY template) of ASP.NET Core in VS 2015, we see the following structure at the start.ย Here you can see a couple of things like wwwroot, Dependencies, Startup class and project.json and also youย ย see some other things like “References” and “Properties” these are the common parts of the .NET application.
ย
ย global.json
The file allows selection of the .NET Core tools version being used through the sdk property.ย The version (and optionally run time and architecture) are important because your computer have multiple versions of dnx.exe (.NET Execution Environment).ย
wwwroot
ASP.NET Core has a new Feature for maintaining wwwroot folder where we put our static contents and libraries so that they are accessible right from the root of the projectย like HTML files, CSS , image files, and JavaScript files which are sent to the users’ browsers should be stored inside the wwwroot folder.
ย Dependencies
There is a special folder called Dependencies which does not present physically but categorically shows the project dependency packages added in the project. Dependencies section is used to manage Bower and NPM tooling packages dependencies in your project. For example, Bower for client-side packages with their dependencies (i.e. jQuery, Bootstrap, Angular).ย Bower has bower.json file which contains all the packages and dependencies that have installed. So Bower and NPM dependencies appear here in this section.ย
ย Program.cs class
Program.cs file is the main entry point of our application. As per below code (inside the program.cs), you can see that this class contains a Main() method whichย looks quite familiar with that you have been seeing in C# Console Apps. This class is used to initiate, build, run the server (IIS and Kestrel) and host theย ย application.ย
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; namespace FirstASPCoreApplication { public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } } } |
ย project.json
The first file of our project is project.json. All top level dependencies and libraries that are used by the application are listed inย project.json.ย The project.json file maintains a list of packages used in a project, known as a package reference format.
ย Startup.cs Class
The startup class is helpful to define the request handling pipeline and configure the Services required by the app. It has 2 methodsย ConfigureServices()ย andย Configure(). This class basically is used to configure middle-wares on the request pipeline.ย The Startup class(Startup.cs) is where application pipeline is configured for request processing.
Web.config
In the previous versions, everything is handled by Web.Config but in ASP.NET Core, we don’t know about Web configure fileย and the only purpose it gives the instruction to iis for what should be done and it receives the http request.
What do you think?
I hope you have overview about ASP .NET Core Layout/structure of the Application. I would like to have feedback from my posts readers. Your valuable feedback, question, or comments about this article are always welcome.
Thanks for the update RG ๐ ur da best ๐