This documentation is archived and is not being maintained.

How to: Enable Output Caching on a Web Service Client

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation .

The following code example demonstrates how to use the Duration property on the client application to specify output caching for a period of 60 seconds. This example illustrates one of the guidelines explained in the topic, Design Guidelines for XML Web Services Created Using ASP.NET.


<%@ Page Language="VB" %>
<%@ Import Namespace="System.Net" %>
<%@ OutputCache Duration="60" VaryByParam="none" %>
   <script language="VB" runat="server">
      Sub EnterBtn_Click(Src As Object, e As EventArgs) 
         Dim math As New MyMath.Math()
         ' Call the Web service.
         Dim addtotal As Single = math.Add(Convert.ToInt32(Num1.Text), _
         ' Display the results in a Label control.
         Total.Text = "Total: " & addtotal.ToString()
      End Sub
   <form action="MathClient.aspx" runat=server>
      <font face="Verdana"> 
         Enter the two numbers you want to add and press 
         the Total button.
         Number 1: 
         <asp:textbox id="Num1" 
         Number 2: 
         <asp:textbox id="Num2" 
         <asp:button id="Total_Button"
         <asp:label id="Total" runat=server/>

See Also