Thursday, September 11, 2014

Use Server.Transfer from a landing page to a page with the real content you want in a web forms application to prevent some back button issues.

If you, for example, have an iFrame with a temporary URL that will not work twice due to modifications being made at the database the first time, then the iFrame is going to cough up an error when someone navigates onto your page with a back button. I got around this in an application I am working on by putting a dummy empty page in front of the page holding the iFrame and redirecting to it through Server.Transfer which, unlike Response.Redirect, does not alter the URL line. I had to introduce some randomness to get it to work in the particular application in front of me. I did so like this:

Server.Transfer("iFrame.aspx?" + Guid.NewGuid());

No comments:

Post a Comment