我是想在任何目录下都能跳转到同一个页面.如果:Response.Write("<script defer>window.alert('你尚未登陆或者当前登陆已超时,请重新登陆!');</script>");
response.redirect("~/index.aspx")
这样可以跳转但是不会弹出。
                                Response.Write("<script defer>window.alert('您没有权限进入本页或当前登录用户已过期!\\n请重新登录或与管理员联系');parent.location.href='" + virtualPath + "index.aspx';</script>");这样可以弹出,但是不会跳到我想要的界面
例如我是在mian/test.aspx界面访问的,那么就跳到这了:
http://localhost:2750/Main/~/Exam/Login.aspx
而不是我需要的跳转。谢谢

解决方案 »

  1.   

            /// <summary>
            /// 弹出消息框并且转向到新的URL
            /// </summary>
            /// <param name="message">消息内容</param>
            /// <param name="toURL">连接地址</param>
            public static void AlertAndRedirect(string message, string toURL)
            {
                #region
                string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>";
                HttpContext.Current.Response.Write(string.Format(js, message, toURL));
                #endregion
            }
    接分咯···
      

  2.   

    string virtualPath=ResolveClientUrl("~/Login.aspx");
      

  3.   


    Response.Write("<script defer>window.alert('您没有权限进入本页或当前登录用户已过期!\\n请重新登录或与管理员联系');parent.location.href='/index.aspx';</script>");
    你可以用html中的 根目录 来相对定位,如果你的不是框架页的话,可以把parent去调.or
    Response.Write("<script defer>window.alert('您没有权限进入本页或当前登录用户已过期!\\n请重新登录或与管理员联系');parent.location.href='"+ResolveUrl(index.aspx)+"';</script>");