In this course of ASP.NET Core, we will cover all the basic, intermediate, and advanced ASP.NET core concepts that help you build data-driven web applications by the end of this course you will be able to perform all the CRUD operations that are Create, Read, Update and Delete using Sequal server as our database.
The topics which we are going to cover in detail are-
- ASP.NET Core.
- ASP.NET Core MVC.
- ASP.NET Core Identity.
- Entity Framework Core.
What is ASP.NET Core?
ASP.NET Core is a cross-platform, high-performance, open-source framework for building modern, cloud-based, Internet-connected applications. ASP.NET Core is a redesign of ASP.NET 4.x and earlier it was named ASP.NET 5 and later is renamed ASP.NET Core.
Few benefits and features of ASP.NET Core.
Cross-Platform: ASP.NET Core applications can be developed and run across different platforms like Windows, macOS, Linux. ASP.NET Core applications can be hosted on IIS, Apache, Docker, and even Self-host in your own process.
Because of One Unified Programming Model for MVC and Web API, both the MVC Controller class and the ASP.NET Web API Controller class inherit from the same Controller base class and returns IActionResult.
ASP.NET Core has great build-in support for Dependency Injection which is a very great feature to learn.
ASP.NET Core Testability feature makes unit testing easy for developers.
It is an Open Source technology so it is continuously growing and improving with the support of developers from the open-source community.
Modular: ASP.NET Core provides modularity with Middleware Components. Both the request and response pipelines are composed using the middleware components. A rich set of built-in middleware components are provided out of the box. Custom Middleware Components can also be created.
Middleware - Is a piece of software that can handle HTTP request or response
Prerequisites for this course:
- Basic understanding of HTML, CSS, and C#.
- Prior MVC knowledge is helpful but not required.
ASP.NET Core Project File.
The Main() method called "CreateWebHostBuilder" and we are passing the command line argument to it. We can notice that "CreateWebHostBuilder" return "IWebHostBuilder" and "Build()" is called on that which build the webhost on which ASP.NET Core Application and on this we add "Run()" and start listening the incoming Http request.
- InProcess or
- OutofProcess.
ASP.NET Core InProcess Hosting.
Dependency Injection in ASP.NET Core.
This is the basic structure of our project when we are not using Dependency Injection and we are using some service(class) inside one or more Controller then we create an object of the service using the "new" keyword and suppose in the future if we make any changes like changing the name of the service then we have to make those changes inside all Controllers. This is an example of tightly coupling.
Now let's understand what happens when we work with Dependency Injection, suppose I have only one service so to work with dependency injection I need to create one interface of my service. Now I will not work directly with the service I will use an interface to create this field and to store the object of this particular service. Now if we are making any changes in service then we don't have to make any changes in the control which is using it.
How to configure Dependency Injection in ASP.NET Core?
- Transient (AddTransient<>) - A new instance of the service will be created every time it is requested.
- Scoped (AddScoped<>) - These are created once per client request. For each HTTP request
- Singleton (AddSingleton<>) - Same instance for the application.
No comments:
Post a Comment