各位大侠,最近刚开始学习c#,碰到了一个头疼的问题:
    我在webconfig中设置了session的timeout属性,我的页面采用了框架,分为上,下两个部分,上面的部分是静态的html文件(如top.html),下面的是主程序部分。当我登陆我的网站之后过一段时间,session失效时,网站重新指向登陆页面,但是登陆页面却被嵌入到了下面的框架中,上面的top.html还在。怎样使我在session失效之后,登陆页面不再被嵌入到框架中,而是独立的一个页面。就像刚登陆这个网站一样

解决方案 »

  1.   

    你可以使用脚本的方式实现,而不能使用redirect的方式进行跳转,示例如下
    Response.Write("<script><alert('登录信息已过期');top.window.location.href='../default.aspx';</script>");
    Response.End();注意,关键之处在top.window.location这一句,加了一个top.
      

  2.   

    parent.window.location.href="http://www.google.com";
      

  3.   

    在你的登录页面如Login.aspx里加上事下代码就行了<script language="javascript">
    <!--
    if (top.location != location) top.location.href = location.href;
    //-->
    </script>
      

  4.   

    <script language="javascript">
    <!--
    if (top.location != location) top.location.href = location.href;
    //-->
    </script>这个就足够了,只在一个页面加上就得了。
      

  5.   

    /// <summary>
    /// 函数名:GotoParentWindow
    /// </summary>
    /// <param name="parentWindowUrl">父窗口</param>
    public static void GotoParentWindow(string parentWindowUrl)
    {
    string js=@"<Script language='JavaScript'>
                        this.parent.location.replace('"+parentWindowUrl+"');</Script>";
    HttpContext.Current.Response.Write(js); 
    }直接调这个方法 传网址