HttpResponseSubstitutionCallback デリゲート
アセンブリ: System.Web (system.web.dll 内)

戻り値
クライアントへの送信前に、キャッシュされた応答に挿入されたコンテンツ。

HttpResponseSubstitutionCallback デリゲートは、WriteSubstitution メソッドと組み合わせて、Substitution コントロールと AdRotator コントロールのキャッシュ後コンテンツの表示に使用します。
Substitution コントロールの場合、MethodName プロパティを使用して、Substitution コントロールの実行時に呼び出すコールバック メソッドの名前を指定します。指定するコールバック メソッドは、ページ上または Substitution コントロールを格納しているユーザー コントロールの静的メソッドであることが必要です。コールバック メソッドのシグネチャは、HttpContext パラメータを受け取って文字列を返す HttpResponseSubstitutionCallback デリゲートのシグネチャと一致する必要があります。
AdRotator コントロールの場合、AdCreated イベントにイベント ハンドラが用意されている場合を除き、表示はページ キャッシュに関係ありません。AdCreated イベント ハンドラが存在しない場合は、AdRotator コンテンツの表示にキャッシュ後置換が使用されます。

Substitution コントロールを、出力キャッシュを使用する Web ページにプログラムによって追加する方法を次のコード例に示します。ページが読み込まれると、ユーザーに対して現在の日付と時刻がラベルに表示されます。ページのこのセクションはキャッシュされ、60 秒ごとに更新されます。Substitution コントロールは、実行されると、GetCurrentDateTime メソッドを呼び出します。このメソッドのシグネチャは HttpResponseSubstitutionCallback デリゲートのシグネチャと一致する必要があります。GetCurrentDateTime メソッドから返される文字列がユーザーに表示されます。ページのこのセクションはキャッシュされず、ページの表示が更新されるたびに更新されます。Substitution コントロールの MethodName プロパティは、コールバック メソッドの名前を取得または設定します。
<%@ outputcache duration="60" varybyparam="none" %> <script runat="server" language="VB"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Programmatically create a Substitution control. Dim Substitution1 As New Substitution ' Specify the callback method. Substitution1.MethodName = "GetCurrentDateTime" ' Add the Substitution control to the controls ' collection of PlaceHolder1. PlaceHolder1.Controls.Add(Substitution1) ' Display the current date and time in the label. ' Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString() End Sub ' The Substitution control calls this method to retrieve ' the current date and time. This section of the page ' is exempt from output caching. Shared Function GetCurrentDateTime(ByVal context As HttpContext) As String Return DateTime.Now.ToString() End Function </script> <html> <head id="Head1" runat="server"> <title>Substitution Constructor Example</title> </head> <body> <form id="Form1" runat="server"> <h3>Substitution Constructor Example</h3> <p>This section of the page is not cached:</p> <asp:placeholder id="PlaceHolder1" runat="Server"> </asp:placeholder> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form> </body> </html>
<%@ outputcache duration="60" varybyparam="none" %> <script runat="server" language="C#"> void Page_Load(object sender, System.EventArgs e) { // Programmatically create a Substitution control. Substitution Substitution1 = new Substitution(); // Specify the callback method. Substitution1.MethodName = "GetCurrentDateTime"; // Add the Substitution control to the controls // collection of PlaceHolder1. PlaceHolder1.Controls.Add (Substitution1); // Display the current date and time in the label. // Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString(); } // The Substitution control calls this method to retrieve // the current date and time. This section of the page // is exempt from output caching. public static string GetCurrentDateTime (HttpContext context) { return DateTime.Now.ToString (); } </script> <html> <head id="Head1" runat="server"> <title>Substitution Class Example</title> </head> <body> <form id="Form1" runat="server"> <h3>Substitution Constructor Example</h3> <p>This section of the page is not cached:</p> <asp:placeholder id="PlaceHolder1" runat="Server"> </asp:placeholder> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


System.Web 名前空間
Substitution
MethodName
AdRotator
AdCreated
WriteSubstitution
その他の技術情報
イベントとデリゲート
ASP.NET ページの一部だけのキャッシュ
Weblioに収録されているすべての辞書からHttpResponseSubstitutionCallback デリゲートを検索する場合は、下記のリンクをクリックしてください。

- HttpResponseSubstitutionCallback デリゲートのページへのリンク