What are the differences between ASP.NET4 and ASP.NET5 Http pipelines?

I read what's new in . NET4.6 and one of the things is ASP.NET 5 , which I'm very excited about.

One of the new things is New modular HTTP request pipeline

, however, there is no more information on how exactly it will change.

The only link in the article

ASP.NET 5 introduces a new HTTP request pipeline that is fast. This pipeline is modular, so you can add only the components you need. By reducing pipeline overhead, your application will perform better. The new pipeline also supports OWIN.

What are the main differences between ASP.NET4.5 and ASP.NET5 Http pipelines? How will modularity be controlled?

+3


source to share


1 answer


The biggest difference, in my opinion, is the modularity of the new request. Previously, the application lifecycle followed a relatively strict path that you could hook into via classes that implement IHttpModule.

This will allow you to influence the request, but only at specific points along the way, subscribing to various events that happen (e.g., BeginRequest,

AuthenticateRequest,

etc.) ...

A full description of them can be found on MSDN: IIS 5 and 6 or IIS 7 , and a step-by-step guide on how to create such a module can be found here.

In the new world of ASP.NET 5, the request pipeline is decoupled from System.Web and IIS. Instead of a predefined path, it uses the concept of middleware. If you are familiar with OWIN , the idea is almost identical , but the basic idea is that these Middleware components are registered and then the request goes through them in the order in which they are registered.



Each middleware component is provided RequestDelegate

(the next middleware component in the pipeline) and current HttpContext

for each request. On each request, the component is called and then has the option to pass the request up to the next in the chain, if applicable. For example, the authentication component can refuse to send the request along with the next component if the authentication fails. Using this system, you can indeed handle the request in any way you choose and can be as light or rich as you need.

This example is a bit outdated (for example, it has IBuilder

been renamed to IApplicationBuilder

), but it still provides a great overview of what creating and registering these components looks like.

+6


source







All Articles