请单击以进行评分并提供反馈
MSDN
MSDN Library
.NET 开发
.NET Framework
 OutputCacheLocation 枚举

  开启低带宽视图
此页面仅适用于
Microsoft Visual Studio 2008/.NET Framework 3.5

同时提供下列产品的其他版本:
.NET Framework 类库
OutputCacheLocation 枚举

更新:2007 年 11 月

指定有效值,用于控制资源的输出缓存 HTTP 响应的位置。

命名空间:  System.Web.UI
程序集:  System.Web(在 System.Web.dll 中)

Visual Basic(声明)
Public Enumeration OutputCacheLocation
Visual Basic (用法)
Dim instance As OutputCacheLocation
C#
public enum OutputCacheLocation
Visual C++
public enum class OutputCacheLocation
J#
public enum OutputCacheLocation
JScript
public enum OutputCacheLocation
成员名称说明
Any输出缓存可位于产生请求的浏览器客户端、参与请求的代理服务器(或任何其他服务器)或处理请求的服务器上。此值对应于 HttpCacheability..::.Public 枚举值。
Client输出缓存位于产生请求的浏览器客户端上。此值对应于 HttpCacheability..::.Private 枚举值。
Downstream输出缓存可存储在任何 HTTP 1.1 可缓存设备中,源服务器除外。这包括代理服务器和发出请求的客户端。
Server输出缓存位于处理请求的 Web 服务器上。此值对应于 HttpCacheability..::.Server 枚举值。
None对于请求的页,禁用输出缓存。此值对应于 HttpCacheability..::.NoCache 枚举值。
ServerAndClient输出缓存只能存储在源服务器或发出请求的客户端中。代理服务器不能缓存响应。此值对应于 HttpCacheability..::.PrivateHttpCacheability..::.Server 枚举值的组合。

如果在 .aspx 文件中包括 @ OutputCache 指令,则使用该枚举指定的值。这些值确定页输出的缓存位置。有关更多信息,请参见 缓存 ASP.NET 页

TopicLocation
如何:以声明方式设置 ASP.NET 页的可缓存性生成 ASP .NET Web 应用程序
如何:以声明方式设置 ASP.NET 页的可缓存性在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:以编程方式设置某个 ASP.NET 页的可缓存性生成 ASP .NET Web 应用程序
如何:以编程方式设置某个 ASP.NET 页的可缓存性在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:使用 HTTP 标头对某页的各个版本进行缓存生成 ASP .NET Web 应用程序
如何:使用 HTTP 标头对某页的各个版本进行缓存在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:使用文件依赖项缓存页输出生成 ASP .NET Web 应用程序
如何:使用文件依赖项缓存页输出在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:使用缓存键依赖项缓存页输出生成 ASP .NET Web 应用程序
如何:使用缓存键依赖项缓存页输出在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:使用请求浏览器缓存页的各个版本生成 ASP .NET Web 应用程序
如何:使用请求浏览器缓存页的各个版本在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:检索缓存项的值生成 ASP .NET Web 应用程序
如何:检索缓存项的值在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:设置 ASP.NET 页缓存的过期时间值生成 ASP .NET Web 应用程序
如何:设置 ASP.NET 页缓存的过期时间值在 Visual Studio 中生成 ASP .NET Web 应用程序

下面的代码示例演示如何使用 Server 值指定应在处理请求的 Web 服务器上缓存页。

Visual Basic
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>

' The following OutputCache directive uses the OutputCacheLocation.Server
' enumeration value to allow output caching only on the origin server.
<%@ outputcache duration="10" varybyparam="none" Location="Server" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
<script language="vb" runat="server">

   Protected Sub Page_Load(Src As [Object], E As EventArgs)
     Dim ds As New DataSet()

     Dim fs As New FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read)


   Dim reader As New StreamReader(fs)

      ds.ReadXml(reader)
      fs.Close()


   Dim [Source] As New DataView(ds.Tables(0))

   MyDataGrid.DataSource = [Source]   
   MyDataGrid.DataBind()

   TimeMsg.Text = DateTime.Now.ToString("G")

 End Sub 'Page_Load 

  </script>

<head runat="server">
    <title>Using the OutputCacheLocation Enumeration </title>
</head>
<body>
  <h4>Using the OutputCacheLocation Enumeration </h4>

  <form id="form1" runat="server">
    <ASP:DataGrid id="MyDataGrid" runat="server"
      Width="900"
      BackColor="#ccccff"
      BorderColor="black"
      ShowFooter="false"
      CellPadding="3"
      CellSpacing="0"
      Font-Names="Verdana"
      Font-Size="8pt"
      HeaderStyle-BackColor="#aaaadd"
      EnableViewState="false"
    />

    <i>Page last generated on:</i> <asp:label id="TimeMsg" runat="server" />

  </form>
</body>
</html>

C#
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>

// The following OutputCache directive uses the OutputCacheLocation.Server
// enumeration value to allow output caching only on the origin server.
<%@ outputcache duration="10" varybyparam="none" Location="Server" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  >
<script language="C#" runat="server">

    protected void Page_Load(Object Src, EventArgs E) 
    {
        DataSet ds = new DataSet();

        FileStream fs = new FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read);
        StreamReader reader = new StreamReader(fs);
        ds.ReadXml(reader);
        fs.Close();

        DataView Source = new DataView(ds.Tables[0]);

        // Use the LiteralControl constructor to create a new
        // instance of the class.
        LiteralControl myLiteral = new LiteralControl();

        // Set the LiteralControl.Text property to an HTML
        // string and the TableName value of a data source.
        myLiteral.Text = "<h6><font face=\"verdana\">Caching an XML Table: " + Source.Table.TableName + " </font></h6>";

        MyDataGrid.DataSource = Source;
        MyDataGrid.DataBind();

        TimeMsg.Text = DateTime.Now.ToString("G");

     }

  </script>

<head runat="server">
    <title>Using the OutputCacheLocation Enumeration </title>
</head>
<body>

  <h6>Using the OutputCacheLocation Enumeration </h6>

  <form id="form1" runat="server">
    <ASP:DataGrid id="MyDataGrid" runat="server"
      Width="900"
      BackColor="#ccccff"
      BorderColor="black"
      ShowFooter="false"
      CellPadding="3"
      CellSpacing="0"
      Font-Names="Verdana"
      Font-Size="8pt"
      HeaderStyle-BackColor="#aaaadd"
      EnableViewState="false"
    />

    <i>Page last generated on:</i> <asp:label id="TimeMsg" runat="server" />

  </form>
</body>
</html>

J#
// The following OutputCache directive uses the OutputCacheLocation.Server
// enumeration value to allow output caching only on the origin server.
<%@ outputcache duration="10" varybyparam="none" Location="Server" %>

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

.NET Framework

受以下版本支持:3.5、3.0、2.0、1.1、1.0
社区内容   什么是社区内容?
添加新内容 RSS  批注
Processing
© 2009 Microsoft Corporation 版权所有。 保留所有权利  |  商标  |  隐私权声明
Page view tracker