ASP.NET CORE PROJECT FILE STRUCTURE PART-I

Understanding of Asp.Net core Project FilesSagar Jaybhay

If you are using C# as a primary programming language then your project file extension is .csproj and if you are using VB as the primary language the .vbproj as a solution.

In the previous version, if we want to modify our project solution file we need to unload project then perform edit and then save and after this, we need to open this. But in this core, we no need to unload project and then edit you can directly do so.

In the previous version whatever you add in your project the reference of this is added to the project file means .csproj file but in this new version or core no references are added in project files.

1.(Target Framework Moniker)TFM:

  1. To set the target framework we have to set in proj file and this is edit by showing below.
ASP.Net core project files
ASP.Net core project files 2

This is TFM netcoreapp2.2.

AspNetCoreHostingModel

This is used for how thee application is hosted which means InProcess or OutOfProcess.

  1. In-process: In this host our asp app inside IIS worker process which uses w3wp.exe
  2. OutOfProcess: In this hosting model forward the web requests to back-end Asp.net core app which is running on a KESTREL server.
  3. By default is In-process hosting

Package Reference

  1. It is used to include a reference of Nuget package which is installed for our application.

MetaPackage

Microsoft.AspNetCore .The app is used to manage or hold the list of dependencies. It is not added default references on its own but it holds the list of dependencies or other packages .

asp.net core 3
asp.net core 4

When we don’t specify the version the implicit version which is specified by SDK is taken.

Main Method in Asp.Net core:-

The Main method present in the program class is the entry point of an application.

At run-time hosting environment search for the Main method and it is a place where application kicks off. Asp.Net application initially starts as a console application.

So Main method is used to configure ASP.NET Core and start it and at that point, console application becomes a Web Application.

public class Program
    {
        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>();
    }

If you see above code Main method is called CreateWebHostBuilder and this method is called the startup class which is an extension method.

This CreateWebHostBuilder is used to create web host builder.

CreateWebHostBuilder Tasks:

  1. Set a web server
  2. It will load host configuration and application configuration from various configuration sources.
  3. You can also configure logging here.

Sagar Jaybhay, from Maharashtra, India, is currently a Senior Software Developer. He has continuously grown in the roles that he has held in the more than seven years he has been with this company. Sagar Jaybhay is an excellent team member and prides himself on his work contributions to his team and company as a whole.

Related posts