您的位置:首页 > 理论基础 > 计算机网络

只能用于会话状态的EnableSessionState设置为true时,无论是在配置文件或Page指令。还请确保在<configuration>\的<system.web>\的<httpModules>在应用程序配置节包括System.We

2011-09-27 17:09 751 查看

Server Error in '/' Application.

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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.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.

Source Error:

An unhandled exception was generated during the execution of the current  web request. Information regarding the origin and location of the  exception can be identified using the exception stack trace below.
出现以上原因是session失效的原因,一般根据服务器不同而产生这样的问题,特别是伪静态

解决方案如下:

1.web.config文件下 找到节点:<system.webServer>,没有就自己加,然后添加以下节点:

<security>
<requestFiltering allowDoubleEscaping="true">
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="All" type="URLRewriter.ModuleRewriter" preCondition="" />
</modules>

2.在web.config中的<authentication mode="Windows"/>后面添加下面的配置信息:

<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="30" />

再不行的话,就不知道了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐