启用/禁用每个控制器/动作方法的会话状态 [英] Enable / disable session state per controller / action method

查看:21
本文介绍了启用/禁用每个控制器/动作方法的会话状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在构建一个 ASP.NET MVC 应用程序,该应用程序将部署在支持缓存等功能的硬件负载平衡器之后.

We are building an ASP.NET MVC application which will be deployed behind a hardware load balancer that supports, among other things, caching.

我们的建议是手动定义负载均衡器应缓存哪些 URL 模式.这对我们来说将是一个非常简单的过程,因为我们有相对静态的目录"页面,然后是相对静态的订购"页面.

Our proposal is to manually define which URL patterns should be cached by the load balancer. This will be quite an easy process for us as we have 'catalogue' pages which are relatively static, then 'order' pages which are not.

必须避免在缓存页面上使用会话状态,因为整个响应都由负载均衡器缓存 - 这包括发送的任何 cookie.

Must avoid using session state on cached pages, as the entire response is cached by the load balancer - this includes any cookies that are sent.

理想情况下,应该有一个属性可以应用于控制器或操作方法,允许有选择地使用会话状态,但似乎没有.我意识到如果使用离开会话区域",这样的方法会导致会话丢失 - 这很好.

Ideally there would be an attribute which can be applied to controllers or action methods which allows selective use of session state, but there doesn't appear to be one. I realise that an approach like this would result in lost sessions if the use leaves the 'session zone' - that's fine.

除了重新实现整个 ASP.NET MVC HTTP 控制器……还有什么建议吗?

Other than re-implementing the entire ASP.NET MVC HTTP controller... any suggestions?

提前致谢.

推荐答案

这包含在 MVC 2 Futures 中.请参阅 http://blogs.msdn.com/rickandy/archive/2009/12/17/session-less-mvc-controller.aspx 了解更多信息.

This is included in MVC 2 Futures. See http://blogs.msdn.com/rickandy/archive/2009/12/17/session-less-mvc-controller.aspx for more info.

这篇关于启用/禁用每个控制器/动作方法的会话状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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