0

My project structure in brief.

I have an Angular2 app, that calls WebApi, that calls code from another project say (CommonProj). CommonProj code is accessing session as below.

if (HttpContext.Current.Session[sessionKey] != null)
{
    // code
}

but it gives me Null Reference error because HttpContext.Current is null. When this code is called from other place i.e. non api it works fine. My question is how to access HttpContext.Current in explained situation.

Imad
  • 7,126
  • 12
  • 55
  • 112
  • I think this is a dupe. See accepted answer at http://stackoverflow.com/questions/19884619/is-it-possible-to-access-httpcontext-current-session-from-web-api – Andy Nichols Nov 22 '16 at 12:03
  • @AndyNichols Request is the property of `HttpContext.Current`, so the same problem will be there too. – Imad Nov 22 '16 at 12:12

0 Answers0