HttpApplication::GetOutputCacheProviderName Method
Gets the name of the default output-cache provider that is configured for a Web site.
Assembly: System.Web (in System.Web.dll)
Parameters
- context
- Type: System.Web::HttpContext
An HttpContext that provides references to intrinsic server objects that are used to service HTTP requests.
| Exception | Condition |
|---|---|
| ProviderException | context is nullptr or is an empty string. |
You can override this method and use it to return the name of any output-cache provider that is configured for a Web site. ASP.NET retrieves a reference to the named provider and uses it to store output-cache data for the currently executing request.
By default, in ASP.NET, all HTTP responses, rendered pages, and controls use the in-memory output cache. You can change the default output-cache provider that is used for a Web application by specifying a different provider name for defaultProvider.
In addition, you can select different output-cache providers for individual control and for individual requests. The easiest way to choose a different output-cache provider for different Web user controls is to do so declaratively by using the new providerName attribute in a page or control directive, as shown in the following example:
<%@ OutputCache Duration="60" VaryByParam="None"
providerName="DiskCache" %>
To specify a different output cache provider for an HTTP request, you override this method in the Global.asax file to programmatically specify which provider to use for a specific request. For more information, see ASP.NET Caching Overview.
The following example shows how to programmatically specify the cache provider named DiskCache for any HTTP request that goes to the Advanced.aspx page.
[Visual Basic]
Public Overloads Overrides Sub GetOutputCacheProviderName(ByVal context _
As HttpContext) As String
If context.Request.Path.EndsWith("Advanced.aspx") Then
Return "DiskCache"
Else
Return MyBase.GetOutputCacheProviderName(context)
End If
End Sub
public override string GetOutputCacheProviderName(HttpContext context) { if (context.Request.Path.EndsWith("Advanced.aspx")) return "DiskCache"; else return base.GetOutputCacheProviderName(context); }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.