How to: Enable Output Caching on a Web Service Client
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

How to: Enable Output Caching on a Web Service Client 

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="C#" %>
<%@ Import Namespace="System.Net" %>
<%@ OutputCache Duration="60" VaryByParam="none" %>
   <script language="C#" runat="server">
      void EnterBtn_Click(Object Src, EventArgs e) 
         MyMath.Math math = new MyMath.Math();
         // Call the Web service.
         float total = math.Add(Convert.ToInt32(Num1.Text),
         // Display the results in a Label control.
         Total.Text = "Total: " + total.ToString();
   <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

© 2016 Microsoft