ASP.NET Identity - HttpContext has no extension method for GetOwinContext





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







344















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 the ASP.NET Identity framework in my project and have ran into a problem, that has driven me mad all day...




GetOwinContext() does not exist as an extension method on my HttpContext




I am implementing the identity framework in class library. I have installed all the latest (pre-release version) of the Identity framework and everything - apart from this - is working fine.



I have tried implementing the same code as the same direct in my controller, and find the same problem.



I'm clearly missing a reference somewhere, though I have no idea what..!..



The code-block that is killing me is:



private IAuthenticationManager AuthenticationManager
{
get
{
return HttpContext.GetOwinContext().Authentication;
}
}


I have added references to the following - tried these both in my class library and also direct on the controller, none of them work for me...



using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using Microsoft.Owin;
using System.Web;


... this is driving me up the wall....any idea?



UPDATE



I have checked the versions of Identity & OWIN in the sample, and I have made sure I have the same versions in my solution.



More so, if I search the object browser on the sample for GetOwinContext I can find the method, however when I search for it in my solution it is nowhere to be found... I must have some library out of date, but I can't find it!










share|improve this question































    344















    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 the ASP.NET Identity framework in my project and have ran into a problem, that has driven me mad all day...




    GetOwinContext() does not exist as an extension method on my HttpContext




    I am implementing the identity framework in class library. I have installed all the latest (pre-release version) of the Identity framework and everything - apart from this - is working fine.



    I have tried implementing the same code as the same direct in my controller, and find the same problem.



    I'm clearly missing a reference somewhere, though I have no idea what..!..



    The code-block that is killing me is:



    private IAuthenticationManager AuthenticationManager
    {
    get
    {
    return HttpContext.GetOwinContext().Authentication;
    }
    }


    I have added references to the following - tried these both in my class library and also direct on the controller, none of them work for me...



    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using Microsoft.Owin.Security;
    using Microsoft.Owin;
    using System.Web;


    ... this is driving me up the wall....any idea?



    UPDATE



    I have checked the versions of Identity & OWIN in the sample, and I have made sure I have the same versions in my solution.



    More so, if I search the object browser on the sample for GetOwinContext I can find the method, however when I search for it in my solution it is nowhere to be found... I must have some library out of date, but I can't find it!










    share|improve this question



























      344












      344








      344


      46






      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 the ASP.NET Identity framework in my project and have ran into a problem, that has driven me mad all day...




      GetOwinContext() does not exist as an extension method on my HttpContext




      I am implementing the identity framework in class library. I have installed all the latest (pre-release version) of the Identity framework and everything - apart from this - is working fine.



      I have tried implementing the same code as the same direct in my controller, and find the same problem.



      I'm clearly missing a reference somewhere, though I have no idea what..!..



      The code-block that is killing me is:



      private IAuthenticationManager AuthenticationManager
      {
      get
      {
      return HttpContext.GetOwinContext().Authentication;
      }
      }


      I have added references to the following - tried these both in my class library and also direct on the controller, none of them work for me...



      using Microsoft.AspNet.Identity;
      using Microsoft.AspNet.Identity.EntityFramework;
      using Microsoft.Owin.Security;
      using Microsoft.Owin;
      using System.Web;


      ... this is driving me up the wall....any idea?



      UPDATE



      I have checked the versions of Identity & OWIN in the sample, and I have made sure I have the same versions in my solution.



      More so, if I search the object browser on the sample for GetOwinContext I can find the method, however when I search for it in my solution it is nowhere to be found... I must have some library out of date, but I can't find it!










      share|improve this question
















      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 the ASP.NET Identity framework in my project and have ran into a problem, that has driven me mad all day...




      GetOwinContext() does not exist as an extension method on my HttpContext




      I am implementing the identity framework in class library. I have installed all the latest (pre-release version) of the Identity framework and everything - apart from this - is working fine.



      I have tried implementing the same code as the same direct in my controller, and find the same problem.



      I'm clearly missing a reference somewhere, though I have no idea what..!..



      The code-block that is killing me is:



      private IAuthenticationManager AuthenticationManager
      {
      get
      {
      return HttpContext.GetOwinContext().Authentication;
      }
      }


      I have added references to the following - tried these both in my class library and also direct on the controller, none of them work for me...



      using Microsoft.AspNet.Identity;
      using Microsoft.AspNet.Identity.EntityFramework;
      using Microsoft.Owin.Security;
      using Microsoft.Owin;
      using System.Web;


      ... this is driving me up the wall....any idea?



      UPDATE



      I have checked the versions of Identity & OWIN in the sample, and I have made sure I have the same versions in my solution.



      More so, if I search the object browser on the sample for GetOwinContext I can find the method, however when I search for it in my solution it is nowhere to be found... I must have some library out of date, but I can't find it!







      c# asp.net asp.net-mvc asp.net-identity






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 10 '17 at 1:30









      Peter Mortensen

      14k1987114




      14k1987114










      asked Jan 15 '14 at 21:07









      Darren WainwrightDarren Wainwright

      21k175998




      21k175998
























          9 Answers
          9






          active

          oldest

          votes


















          653














          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.






          share|improve this answer





















          • 6





            Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

            – frenchie
            Mar 1 '14 at 12:31






          • 21





            @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

            – Darren Wainwright
            Mar 27 '14 at 12:54






          • 5





            @Darren, fair enough. (I do realize I could have worded that differently.)

            – tne
            Mar 27 '14 at 15:55






          • 3





            Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

            – Chris Bohatka
            Apr 21 '14 at 14:42






          • 3





            Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

            – Ortund
            Feb 23 '18 at 7:46



















          167














          I believe you need to reference the current HttpContext if you are outside of the controller. The MVC controllers have a base reference to the current context. However, outside of that, you have to explicitly declare you want the current HttpContext



          return HttpContext.Current.GetOwinContext().Authentication;


          As for it not showing up, a new MVC 5 project template using the code you show above (the IAuthenticationManager) has the following using statements at the top of the account controller:



          using System.Threading.Tasks;
          using System.Web;
          using System.Web.Mvc;
          using Microsoft.AspNet.Identity;
          using Microsoft.AspNet.Identity.EntityFramework;
          using Microsoft.Owin.Security;
          using WebApplication2.Models;


          Commenting out each one, it appears the GetOwinContext() is actually a part of the System.Web.Mvc assembly.






          share|improve this answer


























          • Been trying this and just can't find it. - the GetOwinContext() i mean.

            – Darren Wainwright
            Jan 15 '14 at 21:13






          • 2





            @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

            – Tommy
            Jan 15 '14 at 21:21











          • I've been trying to get this to work directly on a controller too - and again can't find it.

            – Darren Wainwright
            Jan 15 '14 at 21:26






          • 1





            This should be the accepted answer. It's a subtle little thing.

            – Umar Farooq Khawaja
            Feb 22 '14 at 12:04






          • 16





            This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

            – David Miani
            Jun 30 '14 at 0:56



















          20














          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?






          share|improve this answer





















          • 1





            This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

            – SouthShoreAK
            Feb 18 '15 at 20:30






          • 1





            This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

            – shannon
            Mar 26 '15 at 8:05











          • ah, ye ol' dll hell in a new shape

            – JustJohn
            Oct 28 '15 at 6:48






          • 1





            Yes, sadly, extension methods can't be resolved automatically.

            – Ronen Festinger
            Nov 23 '17 at 16:57



















          16














          in my case adding Microsoft.AspNet.WebApi.Owin refference via nuget did a trick.






          share|improve this answer
























          • Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

            – OffHeGoes
            Aug 9 '16 at 7:40



















          14














          Make sure you installed the nuget package Microsoft.AspNet.Identity.Owin. Then add System.Net.Http namespace.






          share|improve this answer


























          • I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

            – Darren Wainwright
            Jan 15 '14 at 21:32











          • @Darren Please add package name. Thank you

            – Saturn Technologies
            Dec 18 '16 at 20:42






          • 6





            @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

            – WiSeeker
            Apr 25 '17 at 5:13






          • 1





            I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

            – Max Barraclough
            Jun 11 '18 at 18:44



















          6














          Just using




          HttpContext.Current.GetOwinContext()




          did the trick in my case.






          share|improve this answer































            3














            To get UserManager in API



            return HttpContext.Current.GetOwinContext().GetUserManager<AppUserManager>();


            where AppUserManager is the class that inherits from UserManager.






            share|improve this answer































              3














              I had all the correct packages and usings, but had to built first before I could get GetOwinContext() to work.






              share|improve this answer


























              • How did you fix your build to make it works the first time?

                – Nordes
                Dec 28 '15 at 7:54











              • @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                – Maverick
                Aug 10 '16 at 6:27



















              1














              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 -





              1. You must have reference to Microsoft.AspNet.Identity.Owin;



                using Microsoft.AspNet.Identity.Owin;




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






              share|improve this answer
























                protected by Community May 6 '14 at 17:12



                Thank you for your interest in this question.
                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                Would you like to answer one of these unanswered questions instead?














                9 Answers
                9






                active

                oldest

                votes








                9 Answers
                9






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                653














                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.






                share|improve this answer





















                • 6





                  Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

                  – frenchie
                  Mar 1 '14 at 12:31






                • 21





                  @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

                  – Darren Wainwright
                  Mar 27 '14 at 12:54






                • 5





                  @Darren, fair enough. (I do realize I could have worded that differently.)

                  – tne
                  Mar 27 '14 at 15:55






                • 3





                  Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

                  – Chris Bohatka
                  Apr 21 '14 at 14:42






                • 3





                  Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

                  – Ortund
                  Feb 23 '18 at 7:46
















                653














                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.






                share|improve this answer





















                • 6





                  Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

                  – frenchie
                  Mar 1 '14 at 12:31






                • 21





                  @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

                  – Darren Wainwright
                  Mar 27 '14 at 12:54






                • 5





                  @Darren, fair enough. (I do realize I could have worded that differently.)

                  – tne
                  Mar 27 '14 at 15:55






                • 3





                  Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

                  – Chris Bohatka
                  Apr 21 '14 at 14:42






                • 3





                  Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

                  – Ortund
                  Feb 23 '18 at 7:46














                653












                653








                653







                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.






                share|improve this answer















                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.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 16 '15 at 21:39









                PeteGO

                3,50523157




                3,50523157










                answered Jan 15 '14 at 21:32









                Darren WainwrightDarren Wainwright

                21k175998




                21k175998








                • 6





                  Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

                  – frenchie
                  Mar 1 '14 at 12:31






                • 21





                  @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

                  – Darren Wainwright
                  Mar 27 '14 at 12:54






                • 5





                  @Darren, fair enough. (I do realize I could have worded that differently.)

                  – tne
                  Mar 27 '14 at 15:55






                • 3





                  Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

                  – Chris Bohatka
                  Apr 21 '14 at 14:42






                • 3





                  Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

                  – Ortund
                  Feb 23 '18 at 7:46














                • 6





                  Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

                  – frenchie
                  Mar 1 '14 at 12:31






                • 21





                  @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

                  – Darren Wainwright
                  Mar 27 '14 at 12:54






                • 5





                  @Darren, fair enough. (I do realize I could have worded that differently.)

                  – tne
                  Mar 27 '14 at 15:55






                • 3





                  Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

                  – Chris Bohatka
                  Apr 21 '14 at 14:42






                • 3





                  Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

                  – Ortund
                  Feb 23 '18 at 7:46








                6




                6





                Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

                – frenchie
                Mar 1 '14 at 12:31





                Thanks for figuring that one out: I'm using this tutorial asp.net/identity/overview/getting-started/… and it's a missing step

                – frenchie
                Mar 1 '14 at 12:31




                21




                21





                @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

                – Darren Wainwright
                Mar 27 '14 at 12:54





                @tne - thank you for your comment... though I was hardly 'running around aimlessly' - i was following a tutorial from a trusted resource; from the asp.net site no-less. They didn't have that step in their tutorial (it's since been added) - also, the fact people are upvoting both this answer and the original Q also goes to indicate that I wasn't the only one with this issue.

                – Darren Wainwright
                Mar 27 '14 at 12:54




                5




                5





                @Darren, fair enough. (I do realize I could have worded that differently.)

                – tne
                Mar 27 '14 at 15:55





                @Darren, fair enough. (I do realize I could have worded that differently.)

                – tne
                Mar 27 '14 at 15:55




                3




                3





                Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

                – Chris Bohatka
                Apr 21 '14 at 14:42





                Just for reference: nuget.org/packages/Microsoft.Owin.Host.SystemWeb/2.1.0

                – Chris Bohatka
                Apr 21 '14 at 14:42




                3




                3





                Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

                – Ortund
                Feb 23 '18 at 7:46





                Don't know if it was from updating this reference, but I had to change up my assignment a little bit to var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; (Current included where it wasn't there in the question).

                – Ortund
                Feb 23 '18 at 7:46













                167














                I believe you need to reference the current HttpContext if you are outside of the controller. The MVC controllers have a base reference to the current context. However, outside of that, you have to explicitly declare you want the current HttpContext



                return HttpContext.Current.GetOwinContext().Authentication;


                As for it not showing up, a new MVC 5 project template using the code you show above (the IAuthenticationManager) has the following using statements at the top of the account controller:



                using System.Threading.Tasks;
                using System.Web;
                using System.Web.Mvc;
                using Microsoft.AspNet.Identity;
                using Microsoft.AspNet.Identity.EntityFramework;
                using Microsoft.Owin.Security;
                using WebApplication2.Models;


                Commenting out each one, it appears the GetOwinContext() is actually a part of the System.Web.Mvc assembly.






                share|improve this answer


























                • Been trying this and just can't find it. - the GetOwinContext() i mean.

                  – Darren Wainwright
                  Jan 15 '14 at 21:13






                • 2





                  @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

                  – Tommy
                  Jan 15 '14 at 21:21











                • I've been trying to get this to work directly on a controller too - and again can't find it.

                  – Darren Wainwright
                  Jan 15 '14 at 21:26






                • 1





                  This should be the accepted answer. It's a subtle little thing.

                  – Umar Farooq Khawaja
                  Feb 22 '14 at 12:04






                • 16





                  This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

                  – David Miani
                  Jun 30 '14 at 0:56
















                167














                I believe you need to reference the current HttpContext if you are outside of the controller. The MVC controllers have a base reference to the current context. However, outside of that, you have to explicitly declare you want the current HttpContext



                return HttpContext.Current.GetOwinContext().Authentication;


                As for it not showing up, a new MVC 5 project template using the code you show above (the IAuthenticationManager) has the following using statements at the top of the account controller:



                using System.Threading.Tasks;
                using System.Web;
                using System.Web.Mvc;
                using Microsoft.AspNet.Identity;
                using Microsoft.AspNet.Identity.EntityFramework;
                using Microsoft.Owin.Security;
                using WebApplication2.Models;


                Commenting out each one, it appears the GetOwinContext() is actually a part of the System.Web.Mvc assembly.






                share|improve this answer


























                • Been trying this and just can't find it. - the GetOwinContext() i mean.

                  – Darren Wainwright
                  Jan 15 '14 at 21:13






                • 2





                  @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

                  – Tommy
                  Jan 15 '14 at 21:21











                • I've been trying to get this to work directly on a controller too - and again can't find it.

                  – Darren Wainwright
                  Jan 15 '14 at 21:26






                • 1





                  This should be the accepted answer. It's a subtle little thing.

                  – Umar Farooq Khawaja
                  Feb 22 '14 at 12:04






                • 16





                  This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

                  – David Miani
                  Jun 30 '14 at 0:56














                167












                167








                167







                I believe you need to reference the current HttpContext if you are outside of the controller. The MVC controllers have a base reference to the current context. However, outside of that, you have to explicitly declare you want the current HttpContext



                return HttpContext.Current.GetOwinContext().Authentication;


                As for it not showing up, a new MVC 5 project template using the code you show above (the IAuthenticationManager) has the following using statements at the top of the account controller:



                using System.Threading.Tasks;
                using System.Web;
                using System.Web.Mvc;
                using Microsoft.AspNet.Identity;
                using Microsoft.AspNet.Identity.EntityFramework;
                using Microsoft.Owin.Security;
                using WebApplication2.Models;


                Commenting out each one, it appears the GetOwinContext() is actually a part of the System.Web.Mvc assembly.






                share|improve this answer















                I believe you need to reference the current HttpContext if you are outside of the controller. The MVC controllers have a base reference to the current context. However, outside of that, you have to explicitly declare you want the current HttpContext



                return HttpContext.Current.GetOwinContext().Authentication;


                As for it not showing up, a new MVC 5 project template using the code you show above (the IAuthenticationManager) has the following using statements at the top of the account controller:



                using System.Threading.Tasks;
                using System.Web;
                using System.Web.Mvc;
                using Microsoft.AspNet.Identity;
                using Microsoft.AspNet.Identity.EntityFramework;
                using Microsoft.Owin.Security;
                using WebApplication2.Models;


                Commenting out each one, it appears the GetOwinContext() is actually a part of the System.Web.Mvc assembly.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 15 '14 at 21:20

























                answered Jan 15 '14 at 21:09









                TommyTommy

                34.7k574111




                34.7k574111













                • Been trying this and just can't find it. - the GetOwinContext() i mean.

                  – Darren Wainwright
                  Jan 15 '14 at 21:13






                • 2





                  @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

                  – Tommy
                  Jan 15 '14 at 21:21











                • I've been trying to get this to work directly on a controller too - and again can't find it.

                  – Darren Wainwright
                  Jan 15 '14 at 21:26






                • 1





                  This should be the accepted answer. It's a subtle little thing.

                  – Umar Farooq Khawaja
                  Feb 22 '14 at 12:04






                • 16





                  This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

                  – David Miani
                  Jun 30 '14 at 0:56



















                • Been trying this and just can't find it. - the GetOwinContext() i mean.

                  – Darren Wainwright
                  Jan 15 '14 at 21:13






                • 2





                  @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

                  – Tommy
                  Jan 15 '14 at 21:21











                • I've been trying to get this to work directly on a controller too - and again can't find it.

                  – Darren Wainwright
                  Jan 15 '14 at 21:26






                • 1





                  This should be the accepted answer. It's a subtle little thing.

                  – Umar Farooq Khawaja
                  Feb 22 '14 at 12:04






                • 16





                  This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

                  – David Miani
                  Jun 30 '14 at 0:56

















                Been trying this and just can't find it. - the GetOwinContext() i mean.

                – Darren Wainwright
                Jan 15 '14 at 21:13





                Been trying this and just can't find it. - the GetOwinContext() i mean.

                – Darren Wainwright
                Jan 15 '14 at 21:13




                2




                2





                @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

                – Tommy
                Jan 15 '14 at 21:21





                @Darren - I played with the sample template a little bit and may have the assembly you are missing. Looks like you will need to reference System.Web.Mvc from your class project. When commented out, that is what made HttpContext.GetOwinContext() become unknown (and not the Microsoft.Owin.Security assembly)

                – Tommy
                Jan 15 '14 at 21:21













                I've been trying to get this to work directly on a controller too - and again can't find it.

                – Darren Wainwright
                Jan 15 '14 at 21:26





                I've been trying to get this to work directly on a controller too - and again can't find it.

                – Darren Wainwright
                Jan 15 '14 at 21:26




                1




                1





                This should be the accepted answer. It's a subtle little thing.

                – Umar Farooq Khawaja
                Feb 22 '14 at 12:04





                This should be the accepted answer. It's a subtle little thing.

                – Umar Farooq Khawaja
                Feb 22 '14 at 12:04




                16




                16





                This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

                – David Miani
                Jun 30 '14 at 0:56





                This tripped me up. There is a public property HttpContext on the Controller class, so if you inherit from that, HttpContext.GetOwinContext() works as expected. If you inherit from ApiController though, there is no such property. Therefore, HttpContext will refer to the class, which will require you to use Current to access an instance of the class. So if you copy/paste code from a Controller to an ApiController and wonder why it doesn't work, this is the answer for you.

                – David Miani
                Jun 30 '14 at 0:56











                20














                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?






                share|improve this answer





















                • 1





                  This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

                  – SouthShoreAK
                  Feb 18 '15 at 20:30






                • 1





                  This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

                  – shannon
                  Mar 26 '15 at 8:05











                • ah, ye ol' dll hell in a new shape

                  – JustJohn
                  Oct 28 '15 at 6:48






                • 1





                  Yes, sadly, extension methods can't be resolved automatically.

                  – Ronen Festinger
                  Nov 23 '17 at 16:57
















                20














                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?






                share|improve this answer





















                • 1





                  This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

                  – SouthShoreAK
                  Feb 18 '15 at 20:30






                • 1





                  This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

                  – shannon
                  Mar 26 '15 at 8:05











                • ah, ye ol' dll hell in a new shape

                  – JustJohn
                  Oct 28 '15 at 6:48






                • 1





                  Yes, sadly, extension methods can't be resolved automatically.

                  – Ronen Festinger
                  Nov 23 '17 at 16:57














                20












                20








                20







                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?






                share|improve this answer















                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?







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 23 '17 at 16:55

























                answered Jan 29 '15 at 21:14









                Ronen FestingerRonen Festinger

                1,7631727




                1,7631727








                • 1





                  This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

                  – SouthShoreAK
                  Feb 18 '15 at 20:30






                • 1





                  This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

                  – shannon
                  Mar 26 '15 at 8:05











                • ah, ye ol' dll hell in a new shape

                  – JustJohn
                  Oct 28 '15 at 6:48






                • 1





                  Yes, sadly, extension methods can't be resolved automatically.

                  – Ronen Festinger
                  Nov 23 '17 at 16:57














                • 1





                  This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

                  – SouthShoreAK
                  Feb 18 '15 at 20:30






                • 1





                  This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

                  – shannon
                  Mar 26 '15 at 8:05











                • ah, ye ol' dll hell in a new shape

                  – JustJohn
                  Oct 28 '15 at 6:48






                • 1





                  Yes, sadly, extension methods can't be resolved automatically.

                  – Ronen Festinger
                  Nov 23 '17 at 16:57








                1




                1





                This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

                – SouthShoreAK
                Feb 18 '15 at 20:30





                This worked for me as well. I already had the Identity libraries, but it seems to need System.Web.

                – SouthShoreAK
                Feb 18 '15 at 20:30




                1




                1





                This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

                – shannon
                Mar 26 '15 at 8:05





                This has apparently been moving around a lot, both in assemblies and in namespaces. Makes it really painful with it being an extension method. I've updated all of my libraries and this answer reflects where it currently is.

                – shannon
                Mar 26 '15 at 8:05













                ah, ye ol' dll hell in a new shape

                – JustJohn
                Oct 28 '15 at 6:48





                ah, ye ol' dll hell in a new shape

                – JustJohn
                Oct 28 '15 at 6:48




                1




                1





                Yes, sadly, extension methods can't be resolved automatically.

                – Ronen Festinger
                Nov 23 '17 at 16:57





                Yes, sadly, extension methods can't be resolved automatically.

                – Ronen Festinger
                Nov 23 '17 at 16:57











                16














                in my case adding Microsoft.AspNet.WebApi.Owin refference via nuget did a trick.






                share|improve this answer
























                • Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

                  – OffHeGoes
                  Aug 9 '16 at 7:40
















                16














                in my case adding Microsoft.AspNet.WebApi.Owin refference via nuget did a trick.






                share|improve this answer
























                • Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

                  – OffHeGoes
                  Aug 9 '16 at 7:40














                16












                16








                16







                in my case adding Microsoft.AspNet.WebApi.Owin refference via nuget did a trick.






                share|improve this answer













                in my case adding Microsoft.AspNet.WebApi.Owin refference via nuget did a trick.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 1 '15 at 11:59









                DolceVitaDolceVita

                1,14311732




                1,14311732













                • Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

                  – OffHeGoes
                  Aug 9 '16 at 7:40



















                • Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

                  – OffHeGoes
                  Aug 9 '16 at 7:40

















                Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

                – OffHeGoes
                Aug 9 '16 at 7:40





                Yes, this did it for me on the current latest version. The extension method is in this Package, which is Assemby System.Web.Http.Owin and within the Namespace System.Net.Http

                – OffHeGoes
                Aug 9 '16 at 7:40











                14














                Make sure you installed the nuget package Microsoft.AspNet.Identity.Owin. Then add System.Net.Http namespace.






                share|improve this answer


























                • I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

                  – Darren Wainwright
                  Jan 15 '14 at 21:32











                • @Darren Please add package name. Thank you

                  – Saturn Technologies
                  Dec 18 '16 at 20:42






                • 6





                  @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

                  – WiSeeker
                  Apr 25 '17 at 5:13






                • 1





                  I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

                  – Max Barraclough
                  Jun 11 '18 at 18:44
















                14














                Make sure you installed the nuget package Microsoft.AspNet.Identity.Owin. Then add System.Net.Http namespace.






                share|improve this answer


























                • I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

                  – Darren Wainwright
                  Jan 15 '14 at 21:32











                • @Darren Please add package name. Thank you

                  – Saturn Technologies
                  Dec 18 '16 at 20:42






                • 6





                  @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

                  – WiSeeker
                  Apr 25 '17 at 5:13






                • 1





                  I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

                  – Max Barraclough
                  Jun 11 '18 at 18:44














                14












                14








                14







                Make sure you installed the nuget package Microsoft.AspNet.Identity.Owin. Then add System.Net.Http namespace.






                share|improve this answer















                Make sure you installed the nuget package Microsoft.AspNet.Identity.Owin. Then add System.Net.Http namespace.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 17 '16 at 10:45









                Syed Ali hassan

                562315




                562315










                answered Jan 15 '14 at 21:29









                CodeNotFoundCodeNotFound

                13.7k53752




                13.7k53752













                • I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

                  – Darren Wainwright
                  Jan 15 '14 at 21:32











                • @Darren Please add package name. Thank you

                  – Saturn Technologies
                  Dec 18 '16 at 20:42






                • 6





                  @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

                  – WiSeeker
                  Apr 25 '17 at 5:13






                • 1





                  I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

                  – Max Barraclough
                  Jun 11 '18 at 18:44



















                • I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

                  – Darren Wainwright
                  Jan 15 '14 at 21:32











                • @Darren Please add package name. Thank you

                  – Saturn Technologies
                  Dec 18 '16 at 20:42






                • 6





                  @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

                  – WiSeeker
                  Apr 25 '17 at 5:13






                • 1





                  I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

                  – Max Barraclough
                  Jun 11 '18 at 18:44

















                I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

                – Darren Wainwright
                Jan 15 '14 at 21:32





                I had that one in too. Turns out there was another library NOT installed when the Identity stuff was installed.

                – Darren Wainwright
                Jan 15 '14 at 21:32













                @Darren Please add package name. Thank you

                – Saturn Technologies
                Dec 18 '16 at 20:42





                @Darren Please add package name. Thank you

                – Saturn Technologies
                Dec 18 '16 at 20:42




                6




                6





                @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

                – WiSeeker
                Apr 25 '17 at 5:13





                @SaturnTechnologies For me, the other package was Microsoft.Owin.Host.SystemWeb and namespace System.Web

                – WiSeeker
                Apr 25 '17 at 5:13




                1




                1





                I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

                – Max Barraclough
                Jun 11 '18 at 18:44





                I second WiSeeker. For me, this didn't help. Darren's suggestion to install Microsoft.Owin.Host.SystemWeb did the trick though.

                – Max Barraclough
                Jun 11 '18 at 18:44











                6














                Just using




                HttpContext.Current.GetOwinContext()




                did the trick in my case.






                share|improve this answer




























                  6














                  Just using




                  HttpContext.Current.GetOwinContext()




                  did the trick in my case.






                  share|improve this answer


























                    6












                    6








                    6







                    Just using




                    HttpContext.Current.GetOwinContext()




                    did the trick in my case.






                    share|improve this answer













                    Just using




                    HttpContext.Current.GetOwinContext()




                    did the trick in my case.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 11 '18 at 12:25









                    Honza P.Honza P.

                    31047




                    31047























                        3














                        To get UserManager in API



                        return HttpContext.Current.GetOwinContext().GetUserManager<AppUserManager>();


                        where AppUserManager is the class that inherits from UserManager.






                        share|improve this answer




























                          3














                          To get UserManager in API



                          return HttpContext.Current.GetOwinContext().GetUserManager<AppUserManager>();


                          where AppUserManager is the class that inherits from UserManager.






                          share|improve this answer


























                            3












                            3








                            3







                            To get UserManager in API



                            return HttpContext.Current.GetOwinContext().GetUserManager<AppUserManager>();


                            where AppUserManager is the class that inherits from UserManager.






                            share|improve this answer













                            To get UserManager in API



                            return HttpContext.Current.GetOwinContext().GetUserManager<AppUserManager>();


                            where AppUserManager is the class that inherits from UserManager.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered May 9 '17 at 12:57









                            Ashraf MaherAshraf Maher

                            617




                            617























                                3














                                I had all the correct packages and usings, but had to built first before I could get GetOwinContext() to work.






                                share|improve this answer


























                                • How did you fix your build to make it works the first time?

                                  – Nordes
                                  Dec 28 '15 at 7:54











                                • @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                                  – Maverick
                                  Aug 10 '16 at 6:27
















                                3














                                I had all the correct packages and usings, but had to built first before I could get GetOwinContext() to work.






                                share|improve this answer


























                                • How did you fix your build to make it works the first time?

                                  – Nordes
                                  Dec 28 '15 at 7:54











                                • @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                                  – Maverick
                                  Aug 10 '16 at 6:27














                                3












                                3








                                3







                                I had all the correct packages and usings, but had to built first before I could get GetOwinContext() to work.






                                share|improve this answer















                                I had all the correct packages and usings, but had to built first before I could get GetOwinContext() to work.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Mar 16 '18 at 16:35









                                CodeNotFound

                                13.7k53752




                                13.7k53752










                                answered Mar 6 '15 at 1:52









                                Kevin RaffayKevin Raffay

                                773418




                                773418













                                • How did you fix your build to make it works the first time?

                                  – Nordes
                                  Dec 28 '15 at 7:54











                                • @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                                  – Maverick
                                  Aug 10 '16 at 6:27



















                                • How did you fix your build to make it works the first time?

                                  – Nordes
                                  Dec 28 '15 at 7:54











                                • @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                                  – Maverick
                                  Aug 10 '16 at 6:27

















                                How did you fix your build to make it works the first time?

                                – Nordes
                                Dec 28 '15 at 7:54





                                How did you fix your build to make it works the first time?

                                – Nordes
                                Dec 28 '15 at 7:54













                                @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                                – Maverick
                                Aug 10 '16 at 6:27





                                @Nordes Sometimes VS fails to build in the background (ie: it tells you there are compile errors), but triggering a real build (or more often clean and then build) will get it through. That's likely what Kevin was experiencing.

                                – Maverick
                                Aug 10 '16 at 6:27











                                1














                                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 -





                                1. You must have reference to Microsoft.AspNet.Identity.Owin;



                                  using Microsoft.AspNet.Identity.Owin;




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






                                share|improve this answer






























                                  1














                                  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 -





                                  1. You must have reference to Microsoft.AspNet.Identity.Owin;



                                    using Microsoft.AspNet.Identity.Owin;




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






                                  share|improve this answer




























                                    1












                                    1








                                    1







                                    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 -





                                    1. You must have reference to Microsoft.AspNet.Identity.Owin;



                                      using Microsoft.AspNet.Identity.Owin;




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






                                    share|improve this answer















                                    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 -





                                    1. You must have reference to Microsoft.AspNet.Identity.Owin;



                                      using Microsoft.AspNet.Identity.Owin;




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







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Nov 24 '18 at 18:50

























                                    answered Nov 17 '18 at 7:19









                                    Heemanshu BhallaHeemanshu Bhalla

                                    2,28311537




                                    2,28311537

















                                        protected by Community May 6 '14 at 17:12



                                        Thank you for your interest in this question.
                                        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                        Would you like to answer one of these unanswered questions instead?



                                        Popular posts from this blog

                                        Xamarin.iOS Cant Deploy on Iphone

                                        Glorious Revolution

                                        Dulmage-Mendelsohn matrix decomposition in Python