+ -
当前位置:首页 → 问答吧 → 关于session过期,父页面跳转到登录页的问题

关于session过期,父页面跳转到登录页的问题

时间:2011-12-27

来源:互联网

我的父页面代码
C# code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<frameset>
<FRAMESET frameSpacing=0 rows=80,* frameBorder=0>
    <FRAME name=top src="Top.aspx" frameBorder=0 noResize scrolling=no>
    <FRAMESET frameSpacing=0 frameBorder=0 cols=220,*>
        <FRAME name=menu src="Menu.aspx" frameBorder=0 noResize>
        <FRAME name=Main src="dpset.aspx" frameBorder=0>
    </FRAMESET>
    <NOFRAMES>
            <p>
                This page requires frames, but your browser does not support them.</p>
    </NOFRAMES>
</FRAMESET>
</frameset>
</html>


我在dpset.aspx页面中判断session是否过期:
C# code

protected void Page_Load(object sender, EventArgs e)
    {        
        if (Session["uid"]==null)
        {
            Response.Write("<script>window.parent.location.href='login.aspx';</script>");
        }
}


通过断点跟踪能执行到Response.Write("<script>window.parent.location.href='login.aspx';</script>");可就是不跳转???
可我要是这样写
C# code

protected void Page_Load(object sender, EventArgs e)
    {      
            Response.Write("<script>window.parent.location.href='login.aspx';</script>");
}


不判断session是否过期,父页面就跳转了。
各位大虾,请问这是为什么啊???

作者: AppaleInTheCollapsar   发布时间: 2011-12-27

你用的时候session已经存在了?

作者: dzpzds   发布时间: 2011-12-27

懒得看内从,只看标题,感觉很多人把session丢失叫做session“过期”,这就纯粹会导致自欺欺人的的议论。

作者: sp1234   发布时间: 2011-12-27

内从 --> 内容


嗯,我看了一下你的内容,我觉得让你耍了。丢脸啊!

你不判断,直接(所谓)跳转。你还问别人“为什么”?你不知道代码不骗人,代码是什么流程就是什么流程,骗人都的都是人的嘴巴嘛。

作者: sp1234   发布时间: 2011-12-27

那我不判断直接跳转,和判断了跳转有什么区别呢?都是无错误的按流程执行了,
C# code

if (Session["uid"]==null)
        {
            Response.Write("<script>window.parent.location.href='login.aspx';</script>");
        }


确实是进入了if方法里面执行,
可为什么一个会跳一个不会跳呢??

作者: AppaleInTheCollapsar   发布时间: 2011-12-27

Session都没有了 哪里还来Session["uid"]
if(Session.Count>0)
{
  if (Session["uid"]==null)
  {
  }


}

作者: livelymoon   发布时间: 2011-12-27