SALES: 1-800-867-1380
1 out of 1 rated this helpful - Rate this topic

How to: Configure the ASP.NET Output Cache Provider (Windows Azure Shared Caching)

This topic explains how to configure an ASP.NET web application to use Windows Azure Shared Caching for ASP.NET output caching. The configuration is done by obtaining the cache settings and modifying the web.config file for the target web application.

This topic is specific to Shared Caching. Applications that host Cache on Windows Azure roles can use the NuGet Package Manager instead. If you are using role-based Cache, see Output Cache Provider for Windows Azure Cache.

To use Shared Caching for session state

  1. First prepare your Visual Studio 2012 project to use Windows Azure Cache. For more information, see How to: Prepare Visual Studio to use Windows Azure Shared Caching.

  2. In the Windows Azure Management Portal, select your target cache. For more information about how to create a new Cache, see How to: Create a Cache (Windows Azure Shared Caching).

  3. Expand the Properties pane. Note the value of cache Service URL. This is the host name for your Windows Azure Cache. It can also be referred to as the cache endpoint URI.

  4. Also note the value of the authentication token for your cache. Click the View button in the Authentication Token field to view this information. This is an ACS key that secures access to your cache.

  5. Click the View Client Configuration button on the toolbar.

  6. In the pop-up Client Configuration window, note the XML snippets. The additional section element should be placed at the end of any existing section elements within the configSections element in your web.config file.

  7. The dataCacheClients section should be placed within the configuration element.

    Note that this exposes two dataCacheClient configurations: default and SslEndpoint. The SslEndpoint cache client uses SSL for communications. You can choose to use either cache client configuration depending on your security requirements.

  8. If you want to use Windows Azure for output caching, add the caching section within the System.Web element. Your ASP.NET pages that use output caching will now use your Cache.

  9. If you require SSL communication, change the dataCacheClientName attribute from default to SslEndpoint.


The following example web.config file configures output caching to use Shared Caching.

<?xml version="1.0"?>
    <section name="dataCacheClients"
             type="Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core"
             allowLocation="true" allowDefinition="Everywhere"/>
    <compilation debug="true" targetFramework="4.0">

    <outputCache defaultProvider="DistributedCache">
        <add name="DistributedCache" type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache"
             dataCacheClientName="default" />

    <authentication mode="None"/>

    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>

    <dataCacheClient name="default">
        <host name="your_cache_service_url" cachePort="22233" />
      <securityProperties mode="Message">

    <dataCacheClient name="SslEndpoint">
        <host name="your_cache_service_url" cachePort="22243" />
      <securityProperties mode="Message" sslEnabled="true">

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.