在 ASP.NET MVC3 中使用无会话控制器有哪些场景? [英] What are some scenario's of having a Session-less Controller in ASP.NET MVC3?

查看:17
本文介绍了在 ASP.NET MVC3 中使用无会话控制器有哪些场景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读Guru-Gu's blog post about ASP.NET MVC3 hit RC,他说:-

无会话控制器支持

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

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?

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

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?

推荐答案

Gu 对此发表了评论.引用:

Gu commented about this. Quoting:

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

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.

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

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.

这篇关于在 ASP.NET MVC3 中使用无会话控制器有哪些场景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆