Reputation: 2131
I know in Asp.net MVC controller, we can access the application like this:
HttpContext.Application["AppVar"]
But in the Web api controller, there is no HttpContext, how to access the application Object then?
Upvotes: 12
Views: 13205
Reputation: 59
object context;
if (Request.Properties.TryGetValue("MS_HttpContext", out context))
{
var application= ((HttpContextBase)context).Application;
}
you can get HttpContext object from Request.Propertiies
Upvotes: 0
Reputation: 7591
the http context still exists and it's a core component of ASP.Net. how you gain access to it is the issue at hand.
HttpContext.Current.Application["AppVar"].
Upvotes: 16