在 ASP.NET MVC3 中使用无会话控制器的场景有哪些?

发布于 2024-10-01 06:55:37 字数 602 浏览 6 评论 0原文

阅读 Guru-Gu 关于 ASP.NET MVC3 实现 RC 的博客文章,他说:-

无会话控制器支持

您现在可以表明是否想要 使用会话状态的控制器类 – 如果是这样,您是否希望如此 读/写或只读。读/写或只读。

有人可以解释一下在某些情况下有人可能想要一个无会话控制器吗?或者只读控制器?

我一直在创建 单独的 IIS 网站,我用它来处理所有静态图像/内容,然后让同一个网站关闭会话状态 ...因此不会通过网络发送 cookie。这是类似的场景吗?

Reading Guru-Gu's blog post about ASP.NET MVC3 hitting RC, he says:-

Session-less Controller Support

You can now indicate whether you want a
Controller class to use session-state
– and if so whether you want it to be
read/write or readonly.read/write or readonly.

Can someone explain what are some scenario's someone might want to have a session-less controller? or a read-only controller?

I've always been creating a separate IIS website which I use to handle all static images/content and then have this same website have session state turned off ... so no cookies are sent over the wire. Is this a similar scenario?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁梦 2024-10-08 06:55:37

对此,顾先生发表了评论。引用:

发行说明对此进行了更多介绍(您
可以从下载中下载它们
上面的链接)。会话状态是
设计得只有一个请求
特定用户/会话发生在
时间。所以如果你有一个页面
多个 AJAX 回调发生在
一旦它们被串行处理
服务器上的时尚。去
无会话意味着他们会
并行执行。

一般来说,这是 ASP.NET 中的已知场景。同一用户的会话对象不是线程安全的。这意味着,如果同一用户(相同的会话 ID cookie)向使用会话的页面发送多个请求,这些请求将排队并按顺序而不是并行处理。

Gu commented about this. Quoting:

The release notes cover this more (you
can download them from the download
link above). Session state is
designed so that only one request from
a particular user/session occurs at a
time. So if you have a page that has
multiple AJAX callbacks happening at
once they will be processed in serial
fashion on the server. Going
session-less means that they would
execute in parallel.

This is a known scenario in ASP.NET in general. The session object for the same user is not thread safe. This means that if the same user (same session id cookie) sends multiple requests to a page which uses session those requests will queue and will be processed in series and not in parallel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文