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

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

问题描述

我们正在建立,这将被部署背后支持,除其他事项外的硬件负载平衡器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期货。见的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天全站免登陆