httpcontext and httpapplication

P

phil2phil

can someone tell me the difference between the httpcontext and
httpapplication object, they seems to have similar methods, such as
getting the Response, REquest, Server variables, are there times when
one should be used as opposed to the other?
 
K

Karl Seguin

Request/Server/Session are the same.

HttpApplication actually uses the context to return them...
Here's the code for the HttpApplication.Request

public HttpRequest Request
{
get
{
HttpRequest request1 = null;
if ((this._context != null) && !this._hideRequestResponse)
{
request1 = this._context.Request;
}
if (request1 == null)
{
throw new
HttpException(HttpRuntime.FormatResourceString("Request_not_available"));
}
return request1;
}
}


When you are in a page/usercontrol...just use Request and Response no need
to use Application.Request and HttpContext.Current.Request. They are
properties exposed by the Control class.

when you are in a non-control class, use
HttpContext.Current.Request/Response/....

Other than that, they do offer different functionality. They also offer
different storage capabilities, to learn more about it, check out:
http://openmymind.net/index.aspx?documentId=6 (which only talk about their
storage differences)

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top