那位大虾能帮我解释一下

andrewz 2003-07-29 03:02:41
[C#]
// C# code from within a page, a handler, or Global.asax.
Session.Contents["Message"] = "MyMsg";
Session.Contents["AppStartTime"] = DateTime.Now;
The StaticObjects collection exposes all variable items that have been added to the session-state collection through <object runat="server"> tags with the scope of "Session" within the Global.asax file. For example:
' Global.asax definition.
<OBJECT RUNAT="SERVER" SCOPE="SESSION" ID="MyInfo" PROGID="Scripting.Dictionary">
</OBJECT>
Objects cannot be added to the StaticObjects collection from anywhere else within an ASP.NET application. The collection throws a NotSupportedException if users attempt to add objects directly through code.
Note The ASP.NET page compiler automatically injects member references into all objects stored within the StaticObjects collection at page compilation time.
Page developers can access Session objects directly at page request time without having to go through the StaticObjects collection, as shown in the following example:
<html>
</body>
Number of entries: <%= MyInfo.Count %>
<body>
</html>

最近一个项目要调查这个asp.net的state
在msdn中看到上文所提到的StaticObjects 和 NotSupportedException这2个概念,想请熟悉的大哥,帮帮小弟,解释一下什么是StaticObjects和,如果让那个NotSupportedException出现

务必帮忙,不胜感激


...全文
96 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
vikey 2003-07-30
  • 打赏
  • 举报
回复
up
andrewz 2003-07-30
  • 打赏
  • 举报
回复
没有人指导吗?

110,825

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧