只有在配置文件或Page指令中将enableSessionState设置为true时,才能使用会话状态。还请确保System.Web.SessionStateModule [英] Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule

查看:563
本文介绍了只有在配置文件或Page指令中将enableSessionState设置为true时,才能使用会话状态。还请确保System.Web.SessionStateModule的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



我坚持这个错误信息。任何人都可以给我一个提示吗?


我的代码中的
(ASP.net C#web表格编程),我尝试评估一个会话变量,然后执行一些代码...每次遇到会话评估行时,调试都会弹出此错误消息(见下文)。什么是webconfig中的正确设置来解决这个问题?你能给出一个完整的样本吗?我尝试了消息建议,它仍然弹出。



if(Session [name] == NULL)

//做某事



错误消息

会话状态只能在配置文件或Page指令中将enableSessionState设置为true时使用。还请确保System.Web.SessionStateModule或自定义会话状态模块包含在应用程序配置的\\部分中



提前谢谢< br $> b $ b

dd

Hi experts,

I stuck on this error message. can any one give me a hint?

in my code behind(ASP.net C# web form programming), I try to evaluate a session variable, then execute some codes... debug pops this error message(see below) every time when it runs into the session evaluation line. What is proper setting in webconfig to fix this? can u give a complete sample. I tried as message suggested, it still pops.

if (Session["name"] == NULL)
//Do sth

error message
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the \\ section in the application configuration

Thank you in advance

dd

推荐答案

关注只有在配置中将enableSessionState设置为true时才能使用会话状态 [ ^ ],表示......

Follow Session state can only be used when enableSessionState is set to true either in a configuration[^], which says...
引用:

您是否启用了会话状态在该部分中?



Did you enable the session state in the section as well?

<system.web>
      <pages enablesessionstate="true"> 
 </pages></system.web>



或者您是否将此添加到页面?




Or did you add this to the page?

<%@Page enableSessionState="true"> 



您是否验证了ASP。 NET会话状态管理器服务服务正在运行?在你的截图中,它不是。它设置为启动模式手动,它要求您每次想要使用它时启动它。要启动它,请突出显示该服务,然后单击工具栏上的绿色播放按钮。要自动启动它,请编辑属性并调整启动类型。



或者将SessionState的模式属性设置为InProc,以便状态服务为不需要。




And did you verify that the ASP.NET Session State Manager Service service is running? In your screenshot it isn''t. It''s set to start-up mode Manual which requires you to start it every time you want to make use of it. To start it, highlight the service and click the green play button on the toolbar. To start it automatically, edit the properties and adjust the Start-up type.

Or set the SessionState''s mode property to InProc, so that the state service is not required.

<system.web>
      <sessionState mode="InProc">
 </system.web>



检查MSDN以获取有关在ASP.NET会话状态下存储数据的所有可用选项。



注意:它''让控制器获取v更好来自会话的alue并让它为您的页面/控件(或ViewBag)添加模型的值,这样View不依赖于HttpSession,您可以稍后为此项目选择不同的源代码更改。或者甚至更好,根本不使用会话状态。当你使用大量的异步javascript调用时,它会杀死你的性能。


Check MSDN for all the options available to you with regards to storing data in the ASP.NET session state.

Note: It''s better to have your Controller fetch the value from the session and have it add the value to the Model for your page/control (or to the ViewBag), that way the View doesn''t depend on the HttpSession and you can choose a different source for this item later with minimal code changes. Or even better, not use the session state at all. It can kill you performance when you''re using a lot of async javascript calls.


这篇关于只有在配置文件或Page指令中将enableSessionState设置为true时,才能使用会话状态。还请确保System.Web.SessionStateModule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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