Click to See Complete Forum and Search --> : passing httpcontext


daveander
02-29-2008, 05:42 PM
I'm looking at someone else's code, and I see them passing httpcontext to an object method. is this necessary? I thought the httpcontext was a global object.

existing code looks like

methodname(HttpContext context)
{
x = context.something;
}

can't I just use

methodname()
{
x = HttpContext.something;
}

?

Phil Weber
02-29-2008, 05:58 PM
No, HttpContext is not global. Each Page has a Context property which returns the context of the current request, but if you want to use the HttpContext outside of a Page object, you must pass it.