HttpApplicationState 类

定义

允许共享 ASP.NET 应用程序内多个会话和请求之间的全局信息。Enables sharing of global information across multiple sessions and requests within an ASP.NET application.

public ref class HttpApplicationState sealed : System::Collections::Specialized::NameObjectCollectionBase
public sealed class HttpApplicationState : System.Collections.Specialized.NameObjectCollectionBase
type HttpApplicationState = class
    inherit NameObjectCollectionBase
Public NotInheritable Class HttpApplicationState
Inherits NameObjectCollectionBase
继承
HttpApplicationState

注解

ASP.NET 应用程序是虚拟目录范围内的所有文件、页面、处理程序、模块和代码以及单个 Web 服务器上的子目录的总和。An ASP.NET application is the sum of all files, pages, handlers, modules, and code within the scope of a virtual directory and its subdirectories on a single Web server.

当客户端第一HttpApplicationState次请求特定 ASP.NET 应用程序虚拟目录内的任何 URL 资源时, 将创建类的单个实例。A single instance of an HttpApplicationState class is created the first time a client requests any URL resource from within a particular ASP.NET application virtual directory. 为 Web 服务器上的每个 ASP.NET 应用程序创建一个单独的实例。A separate single instance is created for each ASP.NET application on a Web server. 然后, 将通过内部Application对象公开对每个实例的引用。A reference to each instance is then exposed via the intrinsic Application object.

应用程序状态不会在 Web 场 (其中应用程序托管在多个服务器上) 或 Web 园 (其中, 应用程序托管在同一台计算机上的多个进程中) 之间共享。Application state is not shared across either a Web farm (in which an application is hosted across multiple servers) or a Web garden (in which an application is hosted across multiple processes on the same computer).

属性

AllKeys

获取 HttpApplicationState 集合中的访问键。Gets the access keys in the HttpApplicationState collection.

Contents

获取对 HttpApplicationState 对象的引用。Gets a reference to the HttpApplicationState object.

Count

获取 HttpApplicationState 集合中的对象数。Gets the number of objects in the HttpApplicationState collection.

IsReadOnly

获取或设置一个值,通过该值指示 NameObjectCollectionBase 实例是否为只读的。Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only.

(继承自 NameObjectCollectionBase)
Item[Int32]

通过索引获取单个 HttpApplicationState 对象。Gets a single HttpApplicationState object by index.

Item[String]

通过名称获取单个 HttpApplicationState 对象的值。Gets the value of a single HttpApplicationState object by name.

Keys

获取 NameObjectCollectionBase.KeysCollection 实例,该实例包含 NameObjectCollectionBase 实例中的所有键。Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
StaticObjects

获取由 <object> 标记声明的所有对象,其中范围设置为 ASP.NET 应用程序中的“Application”。Gets all objects declared by an <object> tag where the scope is set to "Application" within the ASP.NET application.

方法

Add(String, Object)

将新的对象添加到 HttpApplicationState 集合中。Adds a new object to the HttpApplicationState collection.

BaseAdd(String, Object)

将具有指定键和值的项添加到 NameObjectCollectionBase 实例中。Adds an entry with the specified key and value into the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseClear()

移除 NameObjectCollectionBase 实例中的所有项。Removes all entries from the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseGet(Int32)

获取 NameObjectCollectionBase 实例的指定索引处的项值。Gets the value of the entry at the specified index of the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseGet(String)

获取 NameObjectCollectionBase 实例中第一个具有指定键的项值。Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseGetAllKeys()

返回 String 数组,该数组包含 NameObjectCollectionBase 实例中的所有键。Returns a String array that contains all the keys in the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseGetAllValues()

返回 Object 数组,该数组包含 NameObjectCollectionBase 实例中的所有值。Returns an Object array that contains all the values in the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseGetAllValues(Type)

返回指定类型的数组,该数组包含 NameObjectCollectionBase 实例中的所有值。Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseGetKey(Int32)

获取 NameObjectCollectionBase 实例的指定索引处的项键。Gets the key of the entry at the specified index of the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseHasKeys()

获取一个值,通过该值指示 NameObjectCollectionBase 实例是否包含键不为 null 的项。Gets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not null.

(继承自 NameObjectCollectionBase)
BaseRemove(String)

移除 NameObjectCollectionBase 实例中具有指定键的项。Removes the entries with the specified key from the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseRemoveAt(Int32)

移除 NameObjectCollectionBase 实例的指定索引处的项。Removes the entry at the specified index of the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseSet(Int32, Object)

设置 NameObjectCollectionBase 实例的指定索引处的项值。Sets the value of the entry at the specified index of the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
BaseSet(String, Object)

NameObjectCollectionBase 实例中第一个具有指定键的项设置值(如果有这样的项);否则将具有指定键和值的项添加到 NameObjectCollectionBase 实例中。Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
Clear()

HttpApplicationState 集合中移除所有对象。Removes all objects from an HttpApplicationState collection.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
Get(Int32)

通过数字索引获取 HttpApplicationState 对象。Gets an HttpApplicationState object by numerical index.

Get(String)

通过名称获取 HttpApplicationState 对象。Gets an HttpApplicationState object by name.

GetEnumerator()

返回循环访问 NameObjectCollectionBase 的枚举器。Returns an enumerator that iterates through the NameObjectCollectionBase.

(继承自 NameObjectCollectionBase)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetKey(Int32)

通过索引获取 HttpApplicationState 对象名。Gets an HttpApplicationState object name by index.

GetObjectData(SerializationInfo, StreamingContext)

实现 ISerializable 接口,并返回序列化 NameObjectCollectionBase 实例所需的数据。Implements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance.

(继承自 NameObjectCollectionBase)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Lock()

锁定对 HttpApplicationState 变量的访问以促进访问同步。Locks access to an HttpApplicationState variable to facilitate access synchronization.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnDeserialization(Object)

实现 ISerializable 接口,并在完成反序列化之后引发反序列化事件。Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.

(继承自 NameObjectCollectionBase)
Remove(String)

HttpApplicationState 集合中移除命名对象。Removes the named object from an HttpApplicationState collection.

RemoveAll()

HttpApplicationState 集合中移除所有对象。Removes all objects from an HttpApplicationState collection.

RemoveAt(Int32)

按索引从集合中移除一个 HttpApplicationState 对象。Removes an HttpApplicationState object from a collection by index.

Set(String, Object)

更新 HttpApplicationState 集合中的对象值。Updates the value of an object in an HttpApplicationState collection.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
UnLock()

取消锁定对 HttpApplicationState 变量的访问以促进访问同步。Unlocks access to an HttpApplicationState variable to facilitate access synchronization.

显式接口实现

ICollection.CopyTo(Array, Int32)

从目标数组的指定索引处开始将整个 NameObjectCollectionBase 复制到兼容的一维 ArrayCopies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

(继承自 NameObjectCollectionBase)
ICollection.IsSynchronized

获取一个值,该值指示对 NameObjectCollectionBase 对象的访问是否同步(线程安全)。Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe).

(继承自 NameObjectCollectionBase)
ICollection.SyncRoot

获取一个对象,该对象可用于同步对 NameObjectCollectionBase 对象的访问。Gets an object that can be used to synchronize access to the NameObjectCollectionBase object.

(继承自 NameObjectCollectionBase)

扩展方法

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

线程安全性

此类型是线程安全的。This type is thread safe.

另请参阅