1

I try to get more understanding of the role of the Owin packages (Microsoft.Owin) in ASP.NET 4 (MVC 5) applications.

When I create a new MVC application with the wizard, it sets me up with an Owin Startup class, but the configuration therein deals only with authentication.

In contrast to ASP.NET 5, there seems to be no need to do a app.RunMvc() - or in fact any kind of app.Run*() or mentioning what comes at the end of the pipeline.

That begs the question of how the apparently existing Owin pipeline is brought into ASP.NET in ASP.NET 4 applications where the dependency on System.Web still exists.

I assume that

  • in ASP.NET 4, the Owin pipeline always implicitly ends with standard ASP.NET routing (from System.Web.Routing) which, in MVC apps, is usually configured with MapRoute on the RouteCollection and comes down to an MvcRouteHandler and
  • in ASP.NET 5, the Owin pipeline should be explicitly ended with an app.Run*() because nothing comes after its end by default.

Is that correct?

mason
  • 31,774
  • 10
  • 77
  • 121
John
  • 6,693
  • 3
  • 51
  • 90
  • More or less. In ASP.NET 4 the OWIN pipeline executes inside a single HttpModule. If you reach the end of he OWIN pipeline it returns control to IIS and the next module runs, e.g. ASP.NET. – Tratcher May 09 '16 at 16:04
  • 1
    In ASP.NET 5 it's not actually an OWIN pipeline, but it looks pretty similar. When you reach the end of the pipeline there is a default component that returns 404. This is also how the OWIN pipeline behaves outside of IIS (e.g. using HttpListener). – Tratcher May 09 '16 at 16:07
  • Ah, the pipeline one builds in the ASP.NET 5 `Startup` thing isn't an Owin pipeline - I confused that because it looks so similar and I assumed the differences were due to versioning. But in both cases, there is a package `Microsoft.Owin` and `Microsoft.AspNet.Owin`, respectively, that introduces the Owin pipeline. It's just that in the case of ASP.NET 5 one has to explicitly say `app.UseOwin()` to install it whereas for ASP.NET 4 it's somehow there without it (I don't have a special Owin model installed in my web.config). – John May 09 '16 at 20:05
  • 1
    In Asp.Net 4 the OwinHttpModule is dynamically registered. – Tratcher May 09 '16 at 23:23
  • @Tratcher Oh, didn't know that was even possible. And in ASP.NET 5, there's no module and `app.UseOwin` merely adds something to the ASP.NET 5 middleware pipeline, I understood that now. – John May 09 '16 at 23:24

0 Answers0