HttpResponseSubstitutionCallback 대리자

정의

캐시 후 대체를 처리하는 메서드를 나타냅니다.

public delegate System::String ^ HttpResponseSubstitutionCallback(HttpContext ^ context);
public delegate string HttpResponseSubstitutionCallback(HttpContext context);
type HttpResponseSubstitutionCallback = delegate of HttpContext -> string
Public Delegate Function HttpResponseSubstitutionCallback(context As HttpContext) As String 

매개 변수

context
HttpContext

캐시 후 대체를 요구하는 컨트롤에 해당 페이지에 대한 HTTP 요청 정보를 포함하는 HttpContext입니다.

반환 값

클라이언트로 보내기 전에 캐시된 응답에 삽입된 내용입니다.

예제

다음 코드 예제에 추가 하는 방법을 보여 줍니다.는 Substitution 출력 캐시 된 웹 페이지에 프로그래밍 방식으로 제어 합니다. 페이지를 로드 하는 경우 현재 날짜 및 시간 레이블에 사용자에 게 표시 됩니다. 페이지의이 섹션에서는 캐시 되 고 60 초 마다 업데이트 됩니다. 경우는 Substitution 컨트롤이 실행, 호출 합니다 GetCurrentDateTime 에 대 한 시그니처와 일치 해야 하는 메서드를를 HttpResponseSubstitutionCallback 대리자입니다. 반환 되는 문자열을 GetCurrentDateTime 메서드는 사용자에 게 표시 됩니다. 페이지의이 섹션에서는 캐시 되지 않은 하 고 페이지를 새로 고칠 때마다 업데이트 됩니다. 합니다 MethodName 의 속성을 Substitution 컨트롤 이름을 콜백 메서드를 가져오거나 설정 합니다.

<%@ outputcache duration="60" varybyparam="none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<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>
<%@ outputcache duration="60" varybyparam="none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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 xmlns="http://www.w3.org/1999/xhtml" >
<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>

설명

HttpResponseSubstitutionCallback 와 함께에서 대리자를 WriteSubstitution 메서드를 한 후 캐시 콘텐츠를 렌더링에 사용 됩니다는 SubstitutionAdRotator 컨트롤입니다.

에 대 한 합니다 Substitution 컨트롤을 사용 하 여는 MethodName 될 때 호출할 콜백 메서드의 이름을 지정 하는 속성을 Substitution 컨트롤이 실행 합니다. 지정 하는 콜백 메서드를 포함 하는 사용자 정의 컨트롤 또는 페이지의 정적 메서드 해야는 Substitution 제어 합니다. 콜백 메서드의 서명을 서명과 일치 해야 합니다는 HttpResponseSubstitutionCallback 사용 하는 대리자는 HttpContext 매개 변수는 문자열을 반환 합니다.

에 대 한 합니다 AdRotator 컨트롤을 렌더링 무관에 대 한 이벤트 처리기가 제공 되지 않는 경우 페이지 캐싱을 AdCreated 이벤트. 없으면 AdCreated 이벤트 처리기가 있는 캐시 후 대체 렌더링 되는 AdRotator 콘텐츠입니다.

확장 메서드

GetMethodInfo(Delegate)

지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.

적용 대상

추가 정보