本帖最后由 net_lover 于 2011-05-19 14:48:01 编辑

解决方案 »

  1.   


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" enableSessionState="True" %>
      

  2.   

    我webconfig里面设置了mode的,就是本地会话,还是不行
      

  3.   

    如果自定义的handler,实现IRequiresSessionState接口
      

  4.   

    你只要吧web.config文件中添加<sessionState mode="InProc"></sessionState>就行了
      

  5.   

    你的session储存方式是什么的?StateSever?
      

  6.   


    如果是StateSever方式的。。还要改注册表。。运行 regedit → 打开注册表 → 找到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters 节点 → 将 AllowRemoteConnection 的键值设置成“1”(1 为允许,0 代表禁止)→ 设置 Port (端口号)
      

  7.   

    现在贴下pagebase.cs代码,是继承的page。这个问题错误就在红色部分,注释红色部分,页面就没这个错,不注释就有错,请问怎么解决。using System;namespace recycle
    {
    /// <summary>
    /// PageBase 的摘要说明。
    /// </summary>
    public class PageBase :System.Web .UI .Page 
    {
    public PageBase()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    }
    override protected void OnInit(EventArgs e)
    {
    this.Init+=new EventHandler(PageBase_Init);
    base.OnInit(e);
    }
    protected void PageBase_Init(object sender,System.EventArgs e)
    {
                            if (Session["user"] == null)
                            {
                                 string s = "<script>if(opener ==null){alert('登陆超时,请 重新登录!');top.location.href='/login.aspx';}else{opener.top.location.href='/login.aspx';window.close();}</script>";
                                 ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script> alert('" + s + "')</script>");
                                 return;
                            }

    }
             
    }
    }
      

  8.   

    web.config文件<?xml version="1.0" encoding="utf-8"?><!--
      有关如何配置 ASP.NET 应用程序的详细消息,请访问
      http://go.microsoft.com/fwlink/?LinkId=169433
      --><configuration>
    <connectionStrings>
    <add name = "sqlserverString" connectionString = "Data Source=PC-201009081007\SQLEXPRESS;Initial Catalog=recycle;User ID=sa;Password=123" />
       <add name = "oracleString" connectionString = "Data Source=10.10.2.153/orcl;Persist Security Info=True;User ID=zhaodan;Password=zhaodan;Unicode=True;" />
        <!-- <add name = "oracleString" connectionString = "Data Source=XE;Persist Security Info=True;User ID=admin;Password=admin;Unicode=True;" />-->
        <add name="DataSource" connectionString="XE"/>
        <add name="userID" connectionString="admin"/>
        <add name="Password" connectionString="admin"/>
    </connectionStrings>
        <system.web>
    <webServices>
    <protocols>
    <add name="HttpSoap"/>
    <add name="HttpPost"/>
    <add name="HttpGet"/>
    <add name="Documentation"/>
    </protocols>
    </webServices>
            <compilation debug="true" targetFramework="4.0" />
          <!-- <authentication mode = "Forms">
    <forms name=".admin" loginUrl="/login.aspx" timeout="1" path="/"></forms>
    </authentication> -->
          <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
          </customErrors>
          <sessionState
                mode="InProc"  
                cookieless="false" 
                timeout="30"
        />
        </system.web>
    </configuration>
      

  9.   

    我是写了  sessionstate的,定义了 mode 的
      

  10.   


    <pages enableSessionState="true"/>
    的配置呢?
      

  11.   

    经过我的经验,错误在这句,
    string s = "<script>if(opener ==null){alert('登陆超时,请 重新登录!');top.location.href='/login.aspx';}else{opener.top.location.href='/login.aspx';window.close();}</script>";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script> alert('" + s + "')</script>");
      

  12.   

    我现在所有的页面都用的pagebase基类,而pagebase继承的是Page
      

  13.   

    我说了啊,是这句的问题,但是不知道怎么错了string s = "<script>if(opener ==null){alert('登陆超时,请 重新登录!');top.location.href='/login.aspx';}else{opener.top.location.href='/login.aspx';window.close();}</script>";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script> alert('" + s + "')</script>");
      

  14.   

    把你的那段代码 写到一个用户控件页的load事件里去
      

  15.   

    在管理工具->服务 将 ASP.NET State Service 启动起来实施,以前我也遇到过 类似的问题
      

  16.   

    public class PageBase :System.Web .UI .Page  
    {
    public PageBase()
    {
      this.Load+=new EventHandler(Basepage_Load);
    }
       
    void Basepage_Load(Object sender,EventArgs e)
     {if (Session["user"] == null)
    string s = "<script>if(opener ==null){alert('登陆超时,请 重新登            录!');top.location.href='/login.aspx';}else{opener.top.location.href='/login.aspx';window.close();}</script>";
    ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script> alert('" + s + "')</script>");
    return;}
    }
    直接这样试试吧 我今天也遇到这种问题 刚好搜到你的帖子 但是我的解决了  就这样写的 与webconfig没关系 代码语法可能有问题 你自己看看吧 祝你要用哦  
      

  17.   

    有人解决了这个问题吗,不是web.config的问题,真见鬼。
      

  18.   

    36楼的正确
    this.Init+=new EventHandler(PageBase_Init);
    将Init改为Load就可以了
    this.Load
      

  19.   

    我也遇到过这问题,我是jquery+ajax+ashx的
    最后发现用ashx总报这个错
     public class DeleteAjax : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    加了个引用就好了
      

  20.   

    楼主:OnInit方法的开始;做一个System.Web.HttpContext.Current的非空判断该问题即可解决
      

  21.   

    pagebase别用构造函数,重载oninit函数在调用完base.oninit(e)后执行你原来构造函数里写的东东就可以啦
      

  22.   

    36楼的方法 解决了不报黄的问题 但是却执行不了Basepage_Load 这个方法,按照36楼上面的代码执行的话