Owin.IAppBuilder does not contain definition for UseWebApi

At some point of time you might had encountered issues with Owin.IAppBuilder giving error in Startup class which states

‘Owin.IAppBuilder’ does not contain a definition for ‘UseWebApi’ and no extension method ‘UseWebApi’ accepting a first argument of type ‘Owin.IAppBuilder’ could be found (are you missing a using directive or an assembly reference?)

This basically happens when try to add route configuration to the OWIN pipeline while using ASP.NET Web API2 OWIN. You might try updating the OWIN package from 3.0.0.0 to 3.0.1.0 using the NuGet command update-package Microsoft.Owin but that will not resolve the issue.

Solution is you need to install Microsoft ASP.NET Web API2 OWIN Self Host which will resolve the issue. You can use the NuGet command Install-Package Microsoft.AspNet.WebApi.OwinSelfHost

image

Leave a Reply

%d bloggers like this: