1

Is it possible to perform a response.redirect within an iFrame to redirect the whole page so that the destination page is viewable full screen and not contained within the iFrame?

Below is the current code behind

public partial class ServerResult : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Any help would be much appreciated :-)

1 Answer 1

1

No.

Response.Redirect is a server command which sends (302 ?) header tells the client to redirect.

you are in the iframe world. you can't tell the server: "Hey , when you send me data - send it to the parent Iframe"

BUT What you can do , is this :

protected void Page_Load(object sender, EventArgs e) {
   ClientScriptManager.RegisterClientScriptBlock(this.GetType(), 
       "aaa", "window.parent.location = 'http://yoursite.com'", true);
}

but you have to remove response.redirect from server.

Edit

var page = HttpContext.Current.Handler as Page;
            if (page != null) page.ClientScript .RegisterClientScriptBlock(typeof(string), "Redirect", "window.parent.location='" + url + "';", true);
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, I tried that, but got a validation error saying Cannot access non-static method 'RegisterClientScriptBlock' in static context.
so pass a parameter to the method public static void RegisterSomeScript(Page page) { page.ClientScript.RegisterStartupScript("Load", "<script>.........</script>"); }
Apologies, but now I am getting Cannot resolve method 'RegisterClientScriptBlock(string, string)' am I missing something?
I've also tried var cm = Page.ClientScript; cm.RegisterClientScriptBlock(GetType(), "Redirect", "window.parent.location='" + url + "';", true); the code does validate, but doesn't fire.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.