C# 类库中跳转页面
/// <summary> /// 验证用户是否已经登录 /// </summary> public void IsLogin() { if (!SessionIsExistence("userid")) //判断Session是否存在 { System.Web.HttpContext.Current.Response.Write("<script>parent.location.href='" + System.Web.HttpContext.Current.Request.ApplicationPath + "/login/Default.html';</script>"); } }
其中,如果跳转的js使用window.location.href的话,在页面使用模板的情况下整个页面是不会跳转的,所以要用parent来跳转到登录页面