Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Response.REdirect within an IFrame

I have this situation of redirecting my asp page from a button within an IFrame.

Response.Redirect in the button click event redirects the IFrame but not the entire page.

Thanks, Vishnu

like image 826
vishnu Avatar asked May 08 '26 08:05

vishnu


1 Answers

You can add a target="_top" to the html <form> element, or redirect using javascript window.top.location = '/path'.

If you have multiple iframe pages, you may want to create a generic page, let's call it FrameRedirector.aspx. Place this code in the body:

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

Then, replace the Response.Redirect code with

string redirect = "/path/to/redirect.aspx?foo=bar";
Response.Redirect("~/FrameRedirector.aspx?url=" + Server.UrlEncode(redirect));
like image 71
The Scrum Meister Avatar answered May 10 '26 21:05

The Scrum Meister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!