What does IAppbuilder.UseWebApi do?

It configures ASP.NET Web API to run on top of OWIN. OWIN abstracts a web server and you can run it on top of both IIS as well as HTTP.SYS which allows you to provide a web server in your own console application. To be more specific the piece that runs on top of IIS or HTTP.SYS is Katana which is an implementation of the OWIN specification.

By calling app.UseWebApi you configure OWIN/Katana to send web requests through ASP.NET Web Api that in OWIN terminology is considered a middleware. This requires the NuGet package Microsoft.AspNet.WebApi.Owin.

Interestingly, ASP.NET MVC 5 cannot be configured as an OWIN/Katana middleware. it depends on System.Web and expects the HttpContext singleton to exist so it has to run on top of IIS. However, several NuGet packages that can be used in MVC projects (e.g. for authentication) is built on top of OWIN instead of taking a dependency on HttpContext which makes them more useful. That is one explanation of why you see OWIN used in a MVC project.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)