UserControl.Application 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为当前 Web 请求获取 Application 对象。
public:
property System::Web::HttpApplicationState ^ Application { System::Web::HttpApplicationState ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.HttpApplicationState Application { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Application : System.Web.HttpApplicationState
Public ReadOnly Property Application As HttpApplicationState
属性值
当前 Web 请求的 HttpApplicationState 对象。
- 属性
示例
以下示例将两个键值对添加到与用户控件关联的应用程序状态(如果用户控件 IsPostBack 的属性返回 false
)。 满足此条件后,代码会通过用户控件Application的属性使用Add该方法添加键及其值。
if (!myControl.IsPostBack)
{
// Add new objects to the HttpApplicationState.
// These will be maintained as long as the application is active.
myControl.Application.Add("Author","Shafeeque");
myControl.Application.Add("Date",new DateTime(2001,6,21));
// Add an object to the cache with expirations
// set to 0.1 minute.
myControl.Cache.Insert("MyData1", "somevalue", null, DateTime.Now.AddMinutes(0.1), Cache.NoSlidingExpiration);
}
If (Not myControl.IsPostBack) Then
' Add new objects to the HttpApplicationState.
' These will be maintained as long as the as the application is active.
myControl.Application.Add("Author","Shafeeque")
myControl.Application.Add("Date",new DateTime(2001,6,21))
' Add an object to the cache with expirations
' set to 0.1 minute.
myControl.Cache.Insert("MyData1", "somevalue", Nothing, DateTime.Now.AddMinutes(0.1), Cache.NoSlidingExpiration)