Reputation: 5846
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
{
get
{
return _userManager ??
HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
}
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 2.0.0.0 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 Microsoft.Owin.Host.SystemWeb
under References I see in the Properties that it is only version 2.0.0.0 - not only does this seem strange, but it also differs from the sample application that shows 2.1.0.0. - 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.
Upvotes: 2
Views: 4147
Reputation: 361
for some reason after doing what's mentioned in the most voted question i had to clean and build the project again for it to work.
Upvotes: 1
Reputation: 5846
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;
:S
Upvotes: 8
Reputation: 2543
I had some similar issues with the Authentication framework last time I started an MVC project. What solved it for me, was to uninstall the Authentication framwork (via Nuget), and install it again. They recently updated the Authentication framework, but I'm not sure the standard MVC project uses the newly update one. Let me know if it works.
Upvotes: 1