只有在配置文件或Page指令中将enableSessionState设置为true时,才可以使用会话状态. [英] Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive..........

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

问题描述

只有在配置文件或Page指令中将enableSessionState设置为true时,才可以使用会话状态.还请确保在应用程序配置的<configuration>\<system.web>\<httpModules>部分中包含System.Web.SessionStateModule或自定义会话状态模块.

朋友,这是宗师,

将值分配给会话时,此错误即将到来时.我将enableSessionState="true"放在我的webconfig中.

我的webconfig代码如下:

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


hi friends this is guru,

when assign the value to session, at the time this error is coming. i put enableSessionState="true" in my webconfig.

my webconfig code is given below:

<pages enablesessionstate="true">
    <httpmodules>
        <add type="System.Web.SessionState.SessionStateModule" name="Session" />
    </httpmodules>


在我的来源中:


in my source:

<%@ Page Language="VB" AutoEventWireup="false" enableSessionState="true" CodeFile="default.aspx.vb" Inherits="_Default" >
</pages>


请帮助我..谢谢


Please help me.. thanks

推荐答案

阅读本文,将对您有所帮助:
Go through this article, it would help: Exploring Session in ASP.Net[^]

It''s explained in the article about enabling/disabling the session.


我一直在为此而苦苦挣扎……但就我而言,解决方案略有不同.按照所有说明修改Webconfig和所有其他内容后,我仍然遇到问题!我在页面构造函数上分配了一个会话变量.
我最终将代码的这一部分移到其他控件的OnLoad事件上,并且成功了!
我想说的是,因为构造函数是在会话变量功能所在的任何其他库之前调用的,因此在构造函数点尚不可用.

希望这对子孙后代有帮助! :)
I''ve been struggling with this...but in my case the solution was slightly different. After following all the instructions to modify Webconfig and all the other stuff, I still had the problem! I had the assignment to a session variable on the page constructor.
I ended up moving that part of the code to the OnLoad event of other control, and it worked!
I want to thing this is because the constructor is called before any other library where the functionality for session variables resides, thus not available yet at the constructor point.

Hope this helps to future generations! :)


我在基础页和主页的构造方法中设置了断点.请在调试器中删除断点,然后问题消失!如果仍然无法使用,请避免在构造函数中读取Session对象.
I had breakpoints set in the constructor methods of the base page, and the main page. Please remove the breakpoints in the debugger and the problem dissappeared! If still not works then please avoid to read the Session object in a constructor.


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

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