asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -


i realize question might seem trivial some, it's these types of things find myself fighting quite bit , want make sense of despite seeming losing battle in .net (for me anyway).

so, if following:

    using system.web; ... applicationuser user = system.web.httpcontext.getowincontext().getusermanager<applicationusermanager>().findbyid(system.web.httpcontext.user.identity.getuserid()); 

that produces error in title , red getowincontext() , error cannot resolve symbol 'getowincontext()'

however, if following (remove system.web in front of httpcontext), works expected (or @ least no errors):

using system.web;     ...     applicationuser user = httpcontext.getowincontext().getusermanager<applicationusermanager>().findbyid(system.web.httpcontext.user.identity.getuserid()); 

however, if (same line that's working using system.web commented out):

    //using system.web;             ... applicationuser user = httpcontext.getowincontext().getusermanager<applicationusermanager>().findbyid(system.web.httpcontext.user.identity.getuserid()); 

it produces same red getowincontext() , error cannot resolve symbol 'getowincontext()'

if google httpcontext can find stems system.web.

so, question why can't use full syntax in first example above? (also mentioned in answer here highest votes: asp.net mvc 5 - identity. how current applicationuser)

update (to address duplicate question reply): while there answer on question may come same conclusion, don't understand how duplicate question. try think of newbie perspective , dissecting smoke , mirrors .net. have never tried learn convoluted in life .net , have @ things many different angles.

i saw question , 1 other regarding using current, neither struck me 1) being answer looking (at time) 2) more importantly, why it's behaving that. sam's answer perfect, although bit on head. but, @ least now, can go research means...

when writing system.web.httpcontext pointing class. when writing httpcontext inside of controller using property named httpcontext return object of httpcontext class. reach same object calling system.web.httpcontext.current static property. therefore write:

system.web.httpcontext.current.getowincontext().getusermanager<applicationusermanager>(); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

php - How do you embed a video into a custom theme on WordPress? -