18

Looking at a standard new MVC 5 project in Visual Studio 2013 you can see that it now includes OWIN.

There's a new OWIN Startup class that configures auth however I can't see how/where MVC5 is registered with OWIN. Where does this happen?

I'm assuming here that all requests pass through OWIN before entering the MVC pipeline. Why else would they include OWIN?

  • Please note: I'm not asking how OWIN is setup, that's easily explained in the docs. I'm interested in how MVC5 uses OWIN.
Daniel Little
  • 16,975
  • 12
  • 69
  • 93
  • Well it looks like ASP.NET vNEXT will be using OWIN and project Helios. – Daniel Little May 13 '14 at 06:24
  • is it just a guess or did you find a source saying that OWIN will be used? If you found a source, would you mind sharing it? – Rune May 13 '14 at 07:09
  • In this post you can see Helios (which runs on OWIN and replaces System.Web) and a unified MVC/Web.Api has been confirmed. http://davidfowl.com/asp-net-vnext/ – Daniel Little May 13 '14 at 12:22

2 Answers2

18

Update: I figured out why MVC5 uses OWIN even though requests are handled by the IIS pipeline instead of OWIN.

MVC5 does not pass through OWIN, however it looks like this could change in the future. Instead MVC currently still needs to pass through the IIS Integrated Pipeline. The reason that OWIN is included in the default MVC project is so that MVC5 can use the Owin middleware components.

From the OWIN middleware in the iis integrated pipeline:

In order for an OMC to participate in this same, event-based execution ordering, the Katana runtime code scans through the startup configuration and subscribes each of the middleware components to an integrated pipeline event.

This does change in ASP.NET vNext as Web.Api and MVC have been combined and abandon System.Web in favour of OWIN and project Helios.

Daniel Little
  • 16,975
  • 12
  • 69
  • 93
8
  • MVC 5 is not registered with OWIN.
  • OWIN is registered to start before application (PreApplicationStartMethod).
  • And at Pre-application-startup, OwinStartup registered class is used to configure current application.

[assembly: OwinStartup(typeof(WebApplication1.Startup))]

The above line in startup.cs will load the class to configure OWIN. Look further OWIN Startup class detection

Community
  • 1
  • 1
jd4u
  • 5,789
  • 2
  • 28
  • 28
  • This doesn't explain why OWIN is used. The reason OWIN is even included is to use the share OWIN middleware components for authentication. That way both OWIN and IIS based applications can use the same authentication libraries. – Daniel Little Dec 19 '13 at 03:17
  • 1
    "how/where MVC5 is registered with OWIN. Where does this happen?" In this context, my answer is appropriate. Your question does not represent "Why" context at all. Surprising... – jd4u Dec 19 '13 at 05:31
  • Adding the 'why' would make your answer more complete though. I think it's strange that you can MVC needs OWIN for something yet fail to explain what. I was clearly trying to figure out why OWIN was now included. – Daniel Little Dec 19 '13 at 06:07
  • I understand your state of mind at present, but the time of writing the question, I can only understand what is written, not the mind behind it. :-), anyway, I'm sure anyone reading question and answers, will get a good insight to all. But I'm pretty sure, for the question presented here, the marked answer is not appropriate. – jd4u Dec 19 '13 at 07:46