I have a class with static functions which need to use the current HttpContext
. Instead of sending the object each time I use these functions, I tried a different approach. I built such a property:
private static HttpContext _http;
private static HttpContext http
{
get
{
if (_http == null)
_http = HttpContext.Current;
return _http;
}
set { _http = value; }
}
In the functions I use http
as my HttpContext
.
The thing it it seems unstable. Is there some problem with this?
UPDATE: I found this works nicely
get
{
return _http ?? HttpContext.Current;
}
Explanations please