ASP.NET: Fixing the missing GetOwinContext method error by adding an Owin NuGet package

Posted: (EET/GMT+2)

 

So you're working on an ASP.NET MVC web application, and you start working with authentication. You end up with the following C# compiler error:

'HttpContext' does not contain a definition for 'GetOwinContext' and
no extension method 'GetOwinContext' accepting a first argument of
type 'HttpContext' could be found (are you missing a using directive
or an assembly reference?)

How would you fix this error? The solution is luckily pretty simple: install the correct NuGet package. More specifically, you need the package called Microsoft.Owin.Host.SystemWeb. This package implements the missing GetOwinContext() method.

Problem solved!