https://stackoverflow.com/questions/5547989/difference-between-httpcontext-request-and-request
Well:
-
HttpContext.Current
is a static property returning the currentHttpContext
for the thread -
HttpContext.Request
is an instance property returning theHttpRequest
for theHttpContext
you call it on -
Page.Request
is an instance property inPage
, returning theRequest
associated with the page you call it on (typically implicitlythis
)
So HttpContext.Current.Request
will use both of the first two properties in order to get the request associated with the current thread. If you're in the thread dealing with a request, that's going to be the same as the Page.Request
within the relevant page which is being rendered.
However, if your rendering kicks off a different thread, the code running in the other thread can still get at the Request
via Page.Request
(because it's just a normal property) but there'll be no HttpContext
associated with the thread - so HttpContext.Current.Request
wouldn't work.
EDIT: To respond to the edited question, in global.asax the Request
property refers to HttpApplication.Request
, and is probably the best approach to use. HttpContext.Request
won't work, because that's trying to access a static property as if it were an instance property. HttpContext.Current.Request
should work, assuming the context has been associated with the thread by that point.