I have downloaded, and successfully ran the ASP.NET Identity sample from here: https://github.com/rustd/AspnetIdentitySample
I am now in the middle of implementing t
Just install this package and your code will work:=> Install-Package Microsoft.Owin.Host.SystemWeb -Version 2.1.0
ARGH!
I found it... I didn't have an extra package, called Microsoft.Owin.Host.SystemWeb
Once i searched and installed this, it worked.
Now - i am not sure if i just missed everything, though found NO reference to such a library or package when going through various tutorials. It also didn't get installed when i installed all this Identity framework... Not sure if it were just me..
EDIT
Although it's in the Microsoft.Owin.Host.SystemWeb
assembly it is an extension method in the System.Web
namespace, so you need to have the reference to the former, and be using
the latter.
For Devs getting this error in Web API Project -
The GetOwinContext extension method is defined in System.Web.Http.Owin
dll and one more package will be needed i.e. Microsoft.Owin.Host.SystemWeb
. This package needs to be installed in your project from nuget.
Link To Package: OWIN Package Install Command -
Install-Package Microsoft.AspNet.WebApi.Owin
Link To System.web Package : Package Install Command -
Install-Package Microsoft.Owin.Host.SystemWeb
In order to resolve this error you need to find why its occurring in your case. Please Cross check below points in your code -
You must have reference to Microsoft.AspNet.Identity.Owin;
using Microsoft.AspNet.Identity.Owin;
Define GetOwinContext()
Under HttpContext.Current
as below -
return _userManager1 ?? HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
OR
return _signInManager ?? HttpContext.Current.GetOwinContext().Get<ApplicationSignInManager>();
Complete Code Where GetOwinContext() is used -
public ApplicationSignInManager SignInManager
{
get
{
return _signInManager ?? HttpContext.Current.GetOwinContext().Get<ApplicationSignInManager>();
}
private set
{
_signInManager = value;
}
}
Namespace's I'm Using in Code File where GetOwinContext() Is used
using AngularJSAuthentication.API.Entities;
using AngularJSAuthentication.API.Models;
using HomeCinema.Common;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security.DataProtection;
I got this error while moving my code from my one project to another.
In my case adding Microsoft.AspNet.WebApi.Owin reference via nuget did the trick.
After trial and error comparing the using statements of my controller and the Asp.Net Template controller
using System.Web;
Solved the problem for me. You are also going to need to add:
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
To use GetUserManager method.
Microsoft couldn't find a way to resolve this automatically with right click and resolve like other missing using statements?
Make sure you installed the nuget package Microsoft.AspNet.Identity.Owin
. Then add System.Net.Http
namespace.