.Net - 无法创建会话变量 [英] .Net - Can't create Session variables
本文介绍了.Net - 无法创建会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个新项目中,我无法创建会话变量。 for
会话[ fileName ] = null ;
我得到了HttpException:
当 enableSessionState 时,会话状态只能用于将设置为 true , 配置文件或在 Page指令中。另请确保System.Web.SessionStateModule或自定义会话状态模块 包含 <结构>&\ LT;&的System.Web GT; \<&的HttpModules GT;部分 应用程序配置。
然后我添加了
< system.web >
< sessionState mode = InProc < span class =code-attribute> timeout = 60 cookieless = false / >
< pages enableSessionState = true / >
< httpModules < span class =code-keyword>>
< remove 名称 = 会话 / >
< add 名称 = 会话 type = System.Web.SessionState.SessionStateModule / >
< / httpModules >
< / system.web >
但仍然有同样的错误。我在其他项目中使用了Session Variables。我想知道为什么我在这个asp项目中遇到错误。谢谢,如果你可以分享你的经验。
解决方案
只回答从OP解决的未答复队列中删除:
猜测问题是由页面本身引起的。此页面存在一些崩溃问题。我在另一个时代工作,没有这样的问题。该线程可以关闭。感谢。
In one new project, I can't create Session variables. for
Session["fileName"] = null;
I got HttpException:
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 <configuration>\<system.web>\<httpModules> section in the application configuration.
Then I added
<system.web>
<sessionState mode="InProc" timeout="60" cookieless="false" />
<pages enableSessionState="true" />
<httpModules>
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
</httpModules>
</system.web>
But still got the same error. I used Session Variables in my other projects well. I wonder why I got error in this asp project. Thanks if you can share your experience.
解决方案
Answered only to remove from unanswered queue -solved by OP:
guess the problem is caused by the page itself. This page exists some crashing issues. I work on another age, and there is no such a problem. This thread can be closed. Thanks.
这篇关于.Net - 无法创建会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文