rwkiii rwkiii - 1 month ago 27
ASP.NET (C#) Question

IOwinContext does not contain a definition for GetUserManager()

I decided to use Account Confirmation and Password Recovery with ASP.NET Identity. I am using Identity 2.1.0. I installed the sample MVC Application from NuGet into an empty project so I could take a look at how it is configured.

After incorporating changes into my project, there is one error I don't understand how to resolve:

'Microsoft.Owin.IOwinContext' does not contain a definition for
'GetUserManager' and no extension method 'GetUserManager' accepting a
first argument of type 'Microsoft.Owin.IOwinContext' could be found
(are you missing a using directive or an assembly
reference?) C:\Users\xxxxx\Source\Repos\xxxxxx\xxxxxx\xxxxxx\Controllers\AccountController.cs 48 69 xxx
xxx xxx

The error is being thrown in my AccountController.cs:

public ApplicationUserManager UserManager
return _userManager ??
private set
_userManager = value;

In the sample application and in my project I see under Properties that both projects have Microsoft.AspNet.Identity.Owin Version installed.

When I right click over GetOwinContext() in my project and Goto Definition, it shows that the metadata is from
Assembly Microsoft.Owin.Host.SystemWeb.dll, v2.1.0.0
, but when I click on
under References I see in the Properties that it is only version - not only does this seem strange, but it also differs from the sample application that shows - this is the only difference I can find.

I don't find any differences other than what is in the bolded paragraph above. It seems wrong, but I'm not sure and I don't know how to fix it if it is wrong.


Right clicking on GetUserManager didn't display the usual Resolve menu item, only Refactor so the issue wasn't obvious, to me anyway... I was able to fix this problem by including a using statement:

using Microsoft.AspNet.Identity.Owin;