Breyta

Deila með


HttpContext.Request Property

Definition

Gets the HttpRequest object for the current HTTP request.

public:
 property System::Web::HttpRequest ^ Request { System::Web::HttpRequest ^ get(); };
public System.Web.HttpRequest Request { get; }
member this.Request : System.Web.HttpRequest
Public ReadOnly Property Request As HttpRequest

Property Value

The HttpRequest for the current HTTP request.

Exceptions

The Web application is running under IIS 7 in Integrated mode.

Remarks

The Request property provides programmatic access to the properties and methods of the HttpRequest class. Because ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpRequest on an .aspx page without using the fully qualified class reference to HttpContext. For example, you can use Request.Browser to get the capabilities of the client browser. However, if you want to use the members of HttpRequest from an ASP.NET code-behind module, you must include a reference to the System.Web namespace in the module and a fully qualified reference to both the currently active request/response context and the class in System.Web that you want to use. For example, in a code-behind page you must specify the fully qualified name HttpContext.Current.Request.Browser.

Note

ASP.NET will throw an exception if you try to use this property when the HttpRequest object is not available. For example, this would be true in the Application_Start method of the Global.asax file, or in a method that is called from the Application_Start method. At that time no HTTP request has been created yet.

Applies to