Author : HASSAN MD TAREQ

ASP.Net Core

  • ASP.NET Core is a free and open-source web framework and successor to ASP.NET
  • It is a modular framework that runs on both the full .NET Framework and the cross-platform .NET Core
  • Cross-platform framework for building modern cloud based internet connected applications, such as web apps, IoT apps and mobile backends
  • It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions
  • ASP.NET allows you to build high-performance, cross-platform web applications. Patterns like MVC and built-in support for Dependency Injection allow you to build applications that are easier to test and maintain

Request response pipeline

ASP.Net core Request response pipeline

Middleware pipeline

ASP.Net core Middleware pipeline

ASP.Net core Middleware pipeline

  • The Kestrel Web server picks up the Request and creates the httpContext and passes it to the First Middleware in the request pipeline
  • Order Matters: middleware is executed in the same order in which they are added in the pipeline. The order is critical for security, performance, and functionality
  • https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-3.1#order
  • Startup.Configure(IApplicationBuilder) to configure an application’s pipeline
    • The UseXXX and RunXXX method extensions allow us to register the Inline Middlewares to the Request pipeline
    • The RunXXX method adds the terminating middleware while middleware added by UseXXX passes to nex/previous middleware

Startup.cs

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        //...
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.Use(async (context, next) =>
        {
            await context.Response.WriteAsync("");
        });

        app.Run(async (context) =>
        {
            await context.Response.WriteAsync("");
        });
    }
}

App execution

ASP.Net core App execution