Page.EnableSessionState相当于在ASP.NET MVC [英] Page.EnableSessionState equivalent in ASP.NET MVC

查看:115
本文介绍了Page.EnableSessionState相当于在ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP.NET的WebForms,可以设置会话状态模式在页面指令:

With ASP.NET WebForms it is possible to set the session state mode in the page directive:

<%@ Page EnableSessionState="true|false|ReadOnly" %>

在ASP.NET MVC(例如每个控制器或每个动作)是相同的配置也是可能的,如果是这样,怎么样?

Is the same configuration also possible in ASP.NET MVC (e.g. per controller or per action) and if so, how?

(换句话说:我可以禁用或设置为只读,每控制器/动作我认为有会话状态会话状态的读/写会导致一些开销,因此,如果会话状态可以把它可能是有益的关闭,如果不是必需的。)

(In other words: can I disable or set to read-only session state per controllers/actions? I assume having the session state read/write will result in some overhead, so it might be useful if session state could be turned off if not required.)

推荐答案

这似乎与ASP.NET MVC 3将有可能拥有会话少控制器,例如看<一个href=\"http://weblogs.asp.net/scottgu/archive/2010/11/09/announcing-the-asp-net-mvc-3-release-candidate.aspx\">ScottGu's博客文章或<一个href=\"http://www.lostechies.com/blogs/dahlbyk/archive/2010/12/06/renderaction-with-asp-net-mvc-3-sessionless-controllers.aspx\">this基思·达尔比发布。

It seems that with ASP.NET MVC 3 it will be possible to have session-less controllers, e.g. see ScottGu's blog post or this post by Keith Dahlby.

这篇关于Page.EnableSessionState相当于在ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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