Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用Iframe登录超时_Asp.net_Iframe_Session Timeout - Fatal编程技术网

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;
}