那位大虾能帮我解释一下

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出现

务必帮忙,不胜感激


...全文
82 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
vikey 2003-07-30
  • 打赏
  • 举报
回复
up
andrewz 2003-07-30
  • 打赏
  • 举报
回复
没有人指导吗?
发帖
C#

10.8w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
帖子事件
创建了帖子
2003-07-29 03:02
社区公告

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