HttpSessionState.StaticObjects 属性

定义

获取由 ASP.NET 应用程序文件 Global.asax 中的 <object Runat="Server" Scope="Session"/> 标记声明的对象的集合。Gets a collection of objects declared by <object Runat="Server" Scope="Session"/> tags within the ASP.NET application file Global.asax.

public:
 property System::Web::HttpStaticObjectsCollection ^ StaticObjects { System::Web::HttpStaticObjectsCollection ^ get(); };
public System.Web.HttpStaticObjectsCollection StaticObjects { get; }
member this.StaticObjects : System.Web.HttpStaticObjectsCollection
Public ReadOnly Property StaticObjects As HttpStaticObjectsCollection

属性值

一个 HttpStaticObjectsCollection,它包含在 Global.asax 文件中声明的对象。An HttpStaticObjectsCollection containing objects declared in the Global.asax file.

示例

下面的代码示例列出idStaticObjects集合中对象的和对象类型。The following code example lists the id and object type of the objects in the StaticObjects collection.

foreach (System.Collections.DictionaryEntry de in Session.StaticObjects)
  Response.Write(de.Key + " is of type " + de.Value.GetType().ToString() + "<br />");
For Each de As System.Collections.DictionaryEntry In Session.StaticObjects
  Response.Write(String.Format("{0} is of type {1}<br />", de.Key, de.Value.GetType()))
Next

注解

如果页面上的对象不支持序列化并且Mode在进程外 (SQLServerStateServer), 则不会创建对象, 也不会将其添加到此集合中。If an object on a page does not support serialization and Mode is out-of-process (SQLServer or StateServer), the object will not be created and will not be added to this collection.

提供StaticObjects属性是为了与 ASP 的早期版本兼容。The StaticObjects property is provided for compatibility with earlier versions of ASP.

适用于

另请参阅