I went through http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana and was wondering what is the difference between HTTP module and owin middleware. Some pointers that i can think of are
1) Owin middleware decouples the application from host/server. So that it is no longer necessary for me to hook my application logic specifically to System.Web
2) Owin middleware are executed in the order they are added ( not sure if the same holds true for HttpModules; may be depends on how i have added them in web.config)
3) HttpModules helps me to attach my code specific to a application events. Owin middleware is independent of these events
Please also let me know of practical example of using a OWIN module and not a HttpModule.
Some more links i ended up reading (i'll keep on adding here as and when i encounter new) http://www.cloudidentity.com/blog/2013/07/23/securing-a-web-api-with-windows-azure-ad-and-katana/
Update : perhaps this has the anwer i was looking for http://www.asp.net/aspnet/overview/owin-and-katana/owin-middleware-in-the-iis-integrated-pipeline
When should I use OWIN Katana?
Thanks.
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.
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.
HttpModule is another part of request processing of ASP.NET. In a single request processing, there can be more than one modules which gets executed. HttpModules take part in processing of the request by handling the Application events. There are number of events which you can handle during the HttpModule processing.
Open Web Interface for . NET (OWIN) defines an abstraction between . NET web servers and web applications. OWIN decouples the web application from the server, which makes OWIN ideal for self-hosting a web application in your own process, outside of IIS.
1) and 3) is correct, 2) is true for HttpModules as well, so no difference. The point is that OWIN doesn't have the very complex infrastructure of ASP.NET requests, and it's host independent. In fact, you can host OWIN applications inside another .NET application if you so desire.
As far as I'm concerned, if you're going with a modern infrastructure, built on ASP.NET MVC, WebApi or such, forget HttpModules. They're part of an infrastructure built ages ago, and for very different problemes than those modern web developers face. It's also usually a lot easier to integrate different services under OWIN (and the built-in OAuth authentication and similart hings are quite handy).
Now, if you're still developing web applications using the "old" WebForms model, HttpModules migth still be a better choice - hosting WebForms in OWIN is possible (and probably works well), but the benefits kind of disappear. However, if you want a thin HTTP end-point, OWIN is just awesome; it's very lightweight and simple compared to the old ASP.NET infrastructure. The fact that it isn't tied strongly to IIS is just a cherry on top. Personally, I still use it with IIS, although I can definitely see a use for a light-weight HTTP server inside a different service. Also, don't forget that IIS version is tied to Windows version - using all the latest features often needs a server upgrade on IIS.
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