更新时间:2023-01-07 07:42:51
在你的网页是一个iframe里面,的Response.Redirect
只重定向相同的页面,那是在iframe,而不是父一 - 一个解决办法是注册一个JavaScript调用,能说父窗口重定向。
When your page is inside an iframe, the Response.Redirect
is only redirect the same page, that is in the iframe, not the parent one - one workaround is to register a javascript call, that can "say" to the parent window to redirect.
例如,你可以这样做:
ClientScript.RegisterStartupScript(this.GetType(), "scriptid",
"window.parent.location.href='redirectpage.aspx'", true);
在code背后到父窗口重定向到一个新的位置。
at code behind to redirect the parent window to a new location.
您可以从任何JavaScript code调用此脚本以同样的方式说顶端窗口重定向。
The same way you can call this script from any javascript code to say to the top window to redirect.
top.location.href = "redirect.aspx" ;
参考: asp.net论坛,结果
How从重定向prevent IFRAME顶层窗口