views:

1193

answers:

6

I have an asp.net application that runs exclusively on IE7 (internal web site).

When a user needs to enter data, I pop up a child window with a form. When the form closes, it calls javascript:window.opener.location.reload(true) so that the new data will display on the main page.

The problem is that the browser complains that it must repost the page. Is there any way to turn this feature off?

+1  A: 

This is a problem with the usual "postback" way of ASP.NET. If you need to reload a page without this warning, this page must come from a GET, not a POST. You could do a Response.Redirect("...") yourself. But this will destroy the use of viewstate.

Erik
+1  A: 

asp.net mvc fixes this issue, not an ie7 only problem but a security feature of most browsers. No fix that I know of except you could just update the content in the main form with js rather than reloading the whole page

redsquare
A: 

I do not believe that there is a way to do that. Instead, why not direct the parent window to a page without a reload.

javascript:window.opener.location='your url'

Rontologist
+1  A: 

It's because the page in window.opener comes from a POST Request Maybe you can use javascript:window.opener.location = window.opener.location; to do just a GET request if the data can be fetched without a POST.

Matthieu
+1  A: 

No, but there is a solution. Its generally considered good design to use a 302 redirect immediately after someone posts data to a page. This prevents that popup from ever occuring. Allow me to elaborate.

1) The user fills in a form and submits data via POST.

2) The backend receives the data and acts upon it.

3) Instead of returning the content to the user, the backend issues a 302 redirect as soon as its done processing the page (possibly redirecting the user back to the exact same url, if need be)

4) The page that the user will see is the page you told their browser to redirect to. They will load up the redirected page with a standard GET request. If they try to refresh the page, it will not repost the data. Problem solved.

dave mankoff
A: 

AFAIK, not via your scripts.

You might try:

window.opener.location = '#';

It should circumvent the browser reposting. And, you can adjust the hash name as needed.

Jonathan Lonowski