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
{
    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.

Answers


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


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.


Need Your Help

IE 6 OR IE Tester -

internet-explorer-6

took me a long time to figure this out and was wondering if it is IE 6, IE TESTER or something i have done.

Best way to access nullable values in c#

c# nhibernate nullable hibernate-criteria

In our C# code, we already test if a variable is null before attempting to access it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.