I'm reading around articles and checking exmaples and I see Owin Middlewares are used the same as WebAPI DelegatingHandler: logging incoming requests, validating headers and so on.
My only understanding is that Owin Middleware comes before DelegatingHandlers in the pipeline. So if you create an Owin middleware for let's say Authorization of users, you're able to deny a forbidden request faster, at a lower level.
Is there any difference in the two, or any advantages/disadvantages using either of them?
OWIN allows web apps to be decoupled from web servers. It defines a standard way for middleware to be used in a pipeline to handle requests and associated responses. ASP.NET Core applications and middleware can interoperate with OWIN-based applications, servers, and middleware.
NET Core and ASP.NET Core are not based on OWIN. But they support plugging in of OWIN Middleware.
Unlike HttpModules, there is full control of what get's executed and in what order. As they are executed in the order in which they are added. Order of middleware for responses is the reverse from that for requests. Middleware is independent of these events.
OWIN (Open Web Interface for . NET) is a standard for an interface between . NET Web applications and Web servers. It is a community-owned open-source project.
I'm also researching this to find out what differences are. I can come up with some idea that may help you. I think about the purpose they are the same, not so much different. But DelegatingHandler is old mechanism compare to owin Owin middlewares:
DelegatingHandler:
It is a part of web api. At this level, we have HttpRequestMessage, HttpResponseMessage, so we can easily manipulate with those rather than owin middleware( for example you can read the data from request message body without worrying we did something that is effecting the message)
By doing that, actually, you are strongly depend on web api pipeline. I'm not saying that you can not reuse it in the furture but it may be happened.
Hope it gives you helpful information about that.
Thanks,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With