Difference between Page.Request and HttpContext.Current.Request

21/08/2008 - 16:17 von Michael Groeger | Report spam
Hi,

can someone explain me what the main difference between
System.Web.UI.Page.Request and HttpContext.Current.Request is? We have
classes which takes the parameters from the Query String
(HttpRequest.QueryString) and so let's us access the values using the scope
operator, something like MyParameters.ProductId instead of
Request.QueryString["ProductId"].

The ctor of the class takes the request's query string and stores it in a
field. It looks like this:

public MyParameters(Page page)
{
this.qs = page != null
? page.Request.QueryString
: HttpContext.Current.Request.QueryString;
}

But whenever MyParameters gets constructed in Unload-phase, the access to
the HttpRequest instance via the page object throws an HttpException, but
HttpContext.Current.Request does not. I am confused, shouldn't that be the
same?

Regards,
Michael
 

Lesen sie die antworten

#1 Thomas Bandt
21/08/2008 - 17:10 | Warnen spam
Michael Groeger schrieb:
can someone explain me what the main difference between
System.Web.UI.Page.Request and HttpContext.Current.Request is?



Imho ist Page.Request nur ein Mapper für
HttpContext.Current.Request, um das Arbeiten innerhalb
von WebForms und UserControls zu erleichtern. Das Objekt
ist in jedem Fall das selbe.

Gruß, Thomas [MVP ASP/ASP.NET]
http://www.69grad.de - Beratung, Entwicklung
http://www.dotnetjob.de - .NET-Stellenmarkt
http://blog.thomasbandt.de - Thomas goes .NET

Ähnliche fragen