Asp.net 使用Iframe登录超时
我正在我的Asp.net 使用Iframe登录超时,asp.net,iframe,session-timeout,Asp.net,Iframe,Session Timeout,我正在我的asp.net页面中使用IFrames。该页面分为两个垂直部分。在左侧我有链接,单击它们,报表查看器控件将在右侧窗格中打开。我的问题是,当会话超时时,由于这种不活动,用户单击Iframe中的某些按钮,登录页面将在Iframe中打开,而不是将主窗口重定向到登录页面。将下面的mentioend代码放在将在Iframe中显示的页面后面的代码中 if (Session["LoginUser"] == null) { this.Page.ClientScript.RegisterClie
asp.net
页面中使用IFrames
。该页面分为两个垂直部分。在左侧我有链接,单击它们,报表查看器控件将在右侧窗格中打开。我的问题是,当会话超时时,由于这种不活动,用户单击Iframe中的某些按钮,登录页面将在Iframe中打开,而不是将主窗口重定向到登录页面。将下面的mentioend代码放在将在Iframe中显示的页面后面的代码中
if (Session["LoginUser"] == null) {
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
Guid.NewGuid().ToString("N"), "self.parent.location='login.aspx';", true);
}
将以下脚本添加到登录页面的标记中-如果在iframe中呈现,则会将主窗口的url设置为登录页面的url
<script type="text/javascript">
if (parent.frames.length > 0) {
parent.location.href = self.document.location;
}
</script>
如果(parent.frames.length>0){
parent.location.href=self.document.location;
}
您必须将此代码添加到登录页
当您从iframe重定向时,它将自动设置窗口大小
<script type="text/javascript>
if (window.frameElement && window.frameElement.nodeName == "IFRAME") {
parent.location = self.location;
}
</script>
if(window.parent.window!=window){
window.top.location.href=window.location.href;
}