Export (0) Print
Expand All

HttpResponse Class

Updated: April 2009

Encapsulates HTTP-response information from an ASP.NET operation.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class HttpResponse sealed

The methods and properties of the HttpResponse class are exposed through the Response property of the HttpApplication, HttpContext, Page, and UserControl classes.

The following methods of the HttpResponse class are supported only in postback scenarios and not in asynchronous postback scenarios:

Partial-page updates are enabled when you use UpdatePanel controls to update selected regions of a page instead of updating the whole page with a postback. For more information, see UpdatePanel Control Overview and Partial-Page Rendering Overview.

TopicLocation
How to: Pass Values Between ASP.NET Web PagesBuilding ASP .NET Web Applications
How to: Pass Values Between ASP.NET Web PagesBuilding ASP .NET Web Applications

The following example draws three overlapping rectangles when the page is requested. The code begins by setting the ContentType property to image/jpeg, so that the entire page will be rendered as a JPEG image. The code then calls the Clear method to ensure that no extraneous content is sent with this response. Next, the code sets the BufferOutput property to true so that the page is completely processed before it is sent to the requesting client. Two objects used to draw the rectangles are then created: a Bitmap and a Graphics object. The variables created in the page are used as coordinates to draw the rectangles and a string that appears inside the largest rectangle.

When the three rectangles and the string that appears inside them are drawn, the Bitmap is saved to the Stream object that is associated with the OutputStream property and its format is set to JPEG. The code calls the Dispose and Dispose methods to release the resources used by the two drawing objects. Lastly, the code calls the Flush method to send the buffered response to the requesting client.

NoteNote:

In code, the HttpResponse object is referred to by the keyword Response. For example, Response.Clear() refers to the HttpResponse::Clear method. The Page class has a property that is named Response that exposes the current instance of HttpResponse.

No code example is currently available or this language may not be supported.

System::Object
  System.Web::HttpResponse

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Date

History

Reason

April 2009

Removed comment that incorrectly stated that this is new for the .NET Framework 3.5.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft