ASP NET Core Main Method | Project Structure
We will learn:- ASP.NET core web application [Type:Blank] project file
- ASP.NET core Main Method
- Application go through
- Basic Requirement
- Microsoft Visual Studio 2019 with ASP.NET Core 3.1
Suggested Videos:
Create ASP.NET Core App & Discussion on available Template
What is ASP.NET Core Blazor?
Project File
- If the project is created with
- C# language means solution extension will be .csproj
- VB language means solution extension will be .vbproj
- Content of project files has been changed a lot in asp.net core
- No file and folder reference in project file
- Now all files and folder will be displayed in the solution explorer
- Immediately changes will be accepted by the file system and the solution
- Similarly for delete operation and subfolder as well
- No unload requires and traditional approach gone
- All dependencies are mentioned under dependencies node
- Right click on project name and Edit Project file
- Target Framework: To specify the target framework we use this element <TargetFramework>
- To specify a target framework we use Target Framework Moniker (TFM).
- netcoreapp3.1 is the Moniker for .NET Core 3.1.
- We have selected .NET Core 3.1 as the target framework from the New Project Dialog box at the time of project creation.
- AspNetCoreHostingModel : There are two types of hosting model in asp.net core InProcess or OutOfProcess.
- InProcess means host our asp.net core app inside of the IIS worker process (w3wp.exe).
- OutOfProcess means ASP.NET Core app running on the Kestrel server.
- We will discuss in detail in our upcoming videos.
Check Version
- Microsoft.AspNetCore.App: All the features of ASP.NET Core 3.1 and Entity Framework Core are included in this Microsoft.AspNetCore.App package. The default project templates targeting ASP.NET Core 3.1.
- You can check the version through right click on the dependency and click on properties.
Main Method() – Pogram.cs
- In the .Net core application, we have program.cs file and in that we have a main method.
- It is just like .Net console application main method which was the starting point
- .Net core app initially start with console app, it also start with Main method.
- As you can see it configure the .net core app with host build and run method.
- Call CreateHostBuilder and return the IHostBuilder object, call the build method which builds a web host for .net core app
- Now Run method is called and app start and listening to the HTTP request.
- CreateDefaultBuilder() method creates and set up a web host with pre-configured defaults.
Configue() – Startup.cs
- In the .Net core application, we have Startup.cs file
- Startup class is also configured by the UseStartup() extension method of IWebHostBuilder class. This class has 2 very imp methods and those are called by the runtime.
- ConfigureServices() –to add service to the container,
- Configure() - Use this method to configure the HTTP request pipeline.
Next : ASP.NET Core Hosting [in/out] process
No comments:
Post a Comment
Your feedback is important.
Visit www.techwebdots.in