PartialCachingAttribute 构造函数

定义

初始化 PartialCachingAttribute 类的新实例。

重载

名称 说明
PartialCachingAttribute(Int32)

使用分配给要缓存的用户控件的指定持续时间初始化类的新实例 PartialCachingAttribute

PartialCachingAttribute(Int32, String, String, String)

初始化类的新实例 PartialCachingAttribute ,指定缓存持续时间、任何 GET 和 POST 值、控件名称和用于改变缓存的自定义输出缓存要求。

PartialCachingAttribute(Int32, String, String, String, Boolean)

初始化类的新实例 PartialCachingAttribute ,指定缓存持续时间、任何 GETPOST 值、控件名称、用于改变缓存的自定义输出缓存要求,以及用户控件输出是否可以与多个页面共享。

PartialCachingAttribute(Int32, String, String, String, String, Boolean)

初始化类的新实例 PartialCachingAttribute ,指定缓存持续时间、任何 GETPOST 值、控件名称、用于改变缓存的自定义输出缓存要求、数据库依赖项以及用户控件输出是否可以与多个页面共享。

PartialCachingAttribute(Int32)

使用分配给要缓存的用户控件的指定持续时间初始化类的新实例 PartialCachingAttribute

public:
 PartialCachingAttribute(int duration);
public PartialCachingAttribute(int duration);
new System.Web.UI.PartialCachingAttribute : int -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer)

参数

duration
Int32

用户控件应保留在输出缓存中的时间(以秒为单位)。

示例

下面的代码示例演示如何将 PartialCachingAttribute(Int32) 构造函数应用于用户控件。 在此示例中,构造函数用于指示可以缓存用户控件并指定缓存持续时间。 该代码示例是 PartialCachingAttribute 类中的一个较大示例的一部分。

// Set the PartialCachingAttribute.Duration property to 20 seconds.
[PartialCaching(20)]
public partial class ctlMine : UserControl
' Set the PartialCachingAttribute.Duration property to 20 seconds.
<PartialCaching(20)> _
Partial Class ctlMine
    Inherits UserControl

适用于

PartialCachingAttribute(Int32, String, String, String)

初始化类的新实例 PartialCachingAttribute ,指定缓存持续时间、任何 GET 和 POST 值、控件名称和用于改变缓存的自定义输出缓存要求。

public:
 PartialCachingAttribute(int duration, System::String ^ varyByParams, System::String ^ varyByControls, System::String ^ varyByCustom);
public PartialCachingAttribute(int duration, string varyByParams, string varyByControls, string varyByCustom);
new System.Web.UI.PartialCachingAttribute : int * string * string * string -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer, varyByParams As String, varyByControls As String, varyByCustom As String)

参数

duration
Int32

缓存用户控件的时间量(以秒为单位)。

varyByParams
String

用于改变输出缓存的字符串的分号分隔列表。 默认情况下,这些字符串对应于使用 GET 方法属性发送的查询字符串值,或者对应于使用 POST 方法发送的参数。 当此属性设置为多个参数时,输出缓存包含每个指定参数请求的文档的不同版本。 可能的值包括“none”、“*”和任何有效的查询字符串或 POST 参数名称。

varyByControls
String

用于改变输出缓存的字符串的分号分隔列表。 这些字符串表示用户控件上属性的完全限定名称。 当此参数用于用户控件时,用户控件输出因每个指定的用户控件属性的缓存而异。

varyByCustom
String

任何表示自定义输出缓存要求的文本。 如果此参数的值为“browser”,则缓存因浏览器名称和主要版本信息而异。 如果输入了自定义字符串,则必须重写 GetVaryByCustomString(HttpContext, String) 应用程序的 Global.asax 文件中的方法。

示例

下面的代码示例演示如何将 PartialCachingAttribute(Int32, String, String, String) 构造函数应用于用户控件。 在此示例中,构造函数用于指示可以缓存用户控件,将缓存持续时间指定为 20 秒,并指定一个名为 state 用户控件输出的控件。

// Set the PartialCachingAttribute.Duration property to
// 20 seconds and the PartialCachingAttribute.VaryByControls
// property to the ID of the server control to vary the output by.
// In this case, it is state, the ID assigned to a DropDownList
// server control.
[PartialCaching(20, null, "state", null)]
' Set the PartialCachingAttribute.Duration property to
' 20 seconds and the PartialCachingAttribute.VaryByControls
' property to the ID of the server control to vary the output by.
' In this case, it is state, the ID assigned to a DropDownList
' server control.
<PartialCaching(20, Nothing, "state", Nothing)> _
Public Class ctlSelect
    Inherits UserControl

适用于

PartialCachingAttribute(Int32, String, String, String, Boolean)

初始化类的新实例 PartialCachingAttribute ,指定缓存持续时间、任何 GETPOST 值、控件名称、用于改变缓存的自定义输出缓存要求,以及用户控件输出是否可以与多个页面共享。

public:
 PartialCachingAttribute(int duration, System::String ^ varyByParams, System::String ^ varyByControls, System::String ^ varyByCustom, bool shared);
public PartialCachingAttribute(int duration, string varyByParams, string varyByControls, string varyByCustom, bool shared);
new System.Web.UI.PartialCachingAttribute : int * string * string * string * bool -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer, varyByParams As String, varyByControls As String, varyByCustom As String, shared As Boolean)

参数

duration
Int32

缓存用户控件的时间量(以秒为单位)。

varyByParams
String

用于改变输出缓存的字符串的分号分隔列表。 默认情况下,这些字符串对应于使用 GET 方法属性发送的查询字符串值,或者使用 POST 该方法发送的参数。 当此属性设置为多个参数时,输出缓存包含每个指定参数请求的文档的不同版本。 可能的值包括“none”、“*”和任何有效的查询字符串或 POST 参数名称。

varyByControls
String

用于改变输出缓存的字符串的分号分隔列表。 这些字符串表示用户控件上属性的完全限定名称。 当此参数用于用户控件时,用户控件输出因每个指定的用户控件属性的缓存而异。

varyByCustom
String

任何表示自定义输出缓存要求的文本。 如果此参数的值为“browser”,则缓存因浏览器名称和主要版本信息而异。 如果输入了自定义字符串,则必须重写 GetVaryByCustomString(HttpContext, String) 应用程序的 Global.asax 文件中的方法。

shared
Boolean

true 如果指示用户控件输出可与多个页面共享,则为 ;否则,为 false.

适用于

PartialCachingAttribute(Int32, String, String, String, String, Boolean)

初始化类的新实例 PartialCachingAttribute ,指定缓存持续时间、任何 GETPOST 值、控件名称、用于改变缓存的自定义输出缓存要求、数据库依赖项以及用户控件输出是否可以与多个页面共享。

public:
 PartialCachingAttribute(int duration, System::String ^ varyByParams, System::String ^ varyByControls, System::String ^ varyByCustom, System::String ^ sqlDependency, bool shared);
public PartialCachingAttribute(int duration, string varyByParams, string varyByControls, string varyByCustom, string sqlDependency, bool shared);
new System.Web.UI.PartialCachingAttribute : int * string * string * string * string * bool -> System.Web.UI.PartialCachingAttribute
Public Sub New (duration As Integer, varyByParams As String, varyByControls As String, varyByCustom As String, sqlDependency As String, shared As Boolean)

参数

duration
Int32

缓存用户控件的时间量(以秒为单位)。

varyByParams
String

用于改变输出缓存的字符串的分号分隔列表。 默认情况下,这些字符串对应于使用 GET 方法属性发送的查询字符串值,或者使用 POST 该方法发送的参数。 当此属性设置为多个参数时,输出缓存包含每个指定参数请求的文档的不同版本。 可能的值包括“none”、“*”和任何有效的查询字符串或 POST 参数名称。

varyByControls
String

用于改变输出缓存的字符串的分号分隔列表。 这些字符串表示用户控件上属性的完全限定名称。 当此参数用于用户控件时,用户控件输出因每个指定的用户控件属性的缓存而异。

varyByCustom
String

任何表示自定义输出缓存要求的文本。 如果此参数的值为“browser”,则缓存因浏览器名称和主要版本信息而异。 如果输入了自定义字符串,则必须重写 GetVaryByCustomString(HttpContext, String) 应用程序的 Global.asax 文件中的方法。

sqlDependency
String

数据库名称和表名称的分隔列表,更改后,会在 ASP.NET 缓存中显式过期缓存项。 这些数据库名称与 Web 配置部分中标识的那些SQL Server缓存依赖项匹配。

shared
Boolean

true 如果指示用户控件输出可与多个页面共享,则为 ;否则,为 false.

适用于