Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
HttpResponse Class
 WriteSubstitution Method
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
HttpResponse..::.WriteSubstitution Method

Allows insertion of response substitution blocks into the response, which allows dynamic generation of specified response regions for output cached responses.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
Public Sub WriteSubstitution ( _
    callback As HttpResponseSubstitutionCallback _
)
Visual Basic (Usage)
Dim instance As HttpResponse
Dim callback As HttpResponseSubstitutionCallback

instance.WriteSubstitution(callback)
C#
public void WriteSubstitution(
    HttpResponseSubstitutionCallback callback
)
Visual C++
public:
void WriteSubstitution(
    HttpResponseSubstitutionCallback^ callback
)
JScript
public function WriteSubstitution(
    callback : HttpResponseSubstitutionCallback
)

Parameters

callback
Type: System.Web..::.HttpResponseSubstitutionCallback
The method, user control, or object to substitute.
ExceptionCondition
ArgumentException

The target of the callback parameter is of type Control.

You can use the WriteSubstitution method for post-cache substitution in your output-cached pages. By passing an HttpContext object to a callback method with a prescribed HttpResponseSubstitutionCallback signature, you can replace output cached content at any given location in the page cache. To initiate the replacement, call the WriteSubstitution method, passing it the callback method, which must be thread safe and can be either of the following:

  • A static method on the container page or user control.

  • A static or instance method on another arbitrary object.

On the first request to the page, the WriteSubstitution calls the HttpResponseSubstitutionCallback delegate to produce the output. Then, it adds a substitution buffer to the response, which retains the delegate to call on future requests. Finally, it degrades client-side cacheability from public to server-only, ensuring future requests to the page re-invoke the delegate by not caching on the client.

NoteNote:

Post-cache substitution is not supported for a cached user control where output caching is applied at the user control level. This is also known as fragment caching. For more information, see Caching Portions of an ASP.NET Page.

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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker