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

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" />

 

 

 

再不行的话,就不知道了

 

 

 

 

转载于:https://www.cnblogs.com/caicainiao/archive/2011/09/27/2193335.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值