c# - IFrame 中的 Response.REdirect

标签 c# asp.net iframe response.redirect

我遇到了从 IFrame 中的按钮重定向我的 asp 页面的情况。

按钮单击事件中的 Response.Redirect 重定向 IFrame 但不是整个页面。

谢谢, 毗湿奴

最佳答案

您可以添加 target="_top"到 html <form>元素,或使用 javascript 重定向 window.top.location = '/path' .

如果您有多个 iframe 页面,您可能想要创建一个通用页面,我们称之为 FrameRedirector.aspx .将这段代码放在正文中:

<script type="text/javascript">
  window.top.location = '<%=Server.UrlDecode(Request.QueryString["url"])%>';
</script>

然后,替换Response.Redirect代码与

string redirect = "/path/to/redirect.aspx?foo=bar";
Response.Redirect("~/FrameRedirector.aspx?url=" + Server.UrlEncode(redirect));

关于c# - IFrame 中的 Response.REdirect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5012631/

相关文章:

c# - 我们什么时候应该使用 public 什么时候使用 private?

c# - 浏览器OPTIONS请求方式和windows授权

c# - 以不会成为 "God object"的方式设计类

c# - 将字符串数组传递给 webservice 方法

c# - 列表框显示两个时间相同的值

javascript - 使用 Firefox 在 css 之前加载 Iframe 内容

c# - 如何在不使用编程语言的装箱支持的情况下将值设为 "box"?

javascript - 如何从 ASP.NET 变量中为 JavaScript 变量提供数据?

javascript - 为什么javascript编辑器使用iframe来实现?

javascript - 在部分不可见/事件时隐藏 iFrame