Clear Method

Clears the entire response buffer. All data written up to that point is discarded. In contrast to Response.Reset() this applies exclusively to the response buffer. Headers, cookies and other setting are not affected.

Syntax

Response.Clear()

Note

Whenever a previous output is to be replaced with a different output, one normally uses Response.Clear(). In an AFP page that produces HTML you may use it as shown in the sample below:

<%

  lcName = Request.Form("username")

%>

<HTML>

<HEAD>

  <TITLE>Example: Response.Clear()</TITLE>

<HEAD>

 

<BODY>

  <h2>Congratulations, You won!</h2>

  <%

    IF lcName = "wOOdy"

      Response.Clear()

      %>

      <HTML>

      <BODY>

      <h2>Sorry, you're a team member...</h2>

      <%

    ENDIF

  %>

  <p>Best wishes, your <i>AFP Team</i></p>

<BODY>

<HTML>

In practice, Response.Clear() usually occurs in those cases where other data is to be returned. Before returning XML data or PDF files you can use Response.Clear() to make sure that no undesired output is present. Such output can arise out of generic code contained in EVENT_PageCallBefore or EVENT_PageCall events.

By the same token, whenever you want to compress or encrypt output data, you will normally retrieve the entire output buffer through Response.Body(), clear it completely through Response.Clear() and then replace it with the compressed or encrypted version through Response.BinaryWrite().

See also

Response.Reset() | Response.nContentLength