c# - Can't find Request.GetOwinContext -


i have been searching hour trying figure out why isn't working.

i have asp.net mvc 5 application webapi. trying request.getowincontext().authentication, can't seem find how include getowincontext. here code:

using system; using system.collections.generic; using system.linq; using system.net; using system.net.http; using system.web; using system.web.mvc; using system.web.security; using taskpro.models;  namespace taskpro.controllers.api {     public class accountcontroller : apicontroller     {         [httppost]         [allowanonymous]         public returnstatus login(loginviewmodel model)         {              if (modelstate.isvalid)             {                 var ctx = request.getowincontext(); // <-- can't find                  return returnstatus.returnstatussuccess();             }              return base.returnstatuserrorsfrommodelstate(modelstate);         }     } } 

from i've read, should part of system.net.http, i've included , still isn't resolving. ctrl-space doesn't give me intellisense options either.

what missing here?

the getowincontext extension method in system.web.http.owin dll needs downloaded nuget package (the nuget package name microsoft.aspnet.webapi.owin)

install-package microsoft.aspnet.webapi.owin 

see msdn here: http://msdn.microsoft.com/en-us/library/system.net.http.owinhttprequestmessageextensions.getowincontext(v=vs.118).aspx

nuget package here: https://www.nuget.org/packages/microsoft.aspnet.webapi.owin

however, method still part of system.net.http namespace, using definitions have should fine.

edit

okay, clear confusion: if using apicontroller (i.e mycontroller : apicontroller) require microsoft.aspnet.webapi.owin package.

if using regular mvc controller (i.e. mycontroller : controller) need microsoft.owin.host.systemweb package.

in mvc 5 pipelines api , regular mvc different, have same naming conventions. extension method in 1 not apply other. same lot of action filters etc.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -