Author : MD TAREQ HASSAN | Updated : 2020/05/25
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
Middleware pipeline
Flow:
- 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
andRunXXX
method extensions allow us to register the Inline Middlewares to the Request pipeline - The
RunXXX
method adds the terminating middleware while middleware added byUseXXX
passes to nex/previous middleware
- The
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("");
});
}
}