views:

96

answers:

3

I have an ASP page that takes two arguments on the querystring. On the page is a form that posts back to itself.

If I do the form post once, and then try to refresh the page, it doesn't repost the form. It loads the page as though it were loading for the first time, missing the querystring values.

Is there a way to ALWAYS force a repost when I refresh a page that is the result of a FORM post?

A: 

Which action does the form use: GET or POST? Normally, a form would use the POST action, but in this case, if you refresh the page with the posted form, you will not get anything in query string, because query string only gets passed via the GET action. Assuming that this issue is not caused by page caching, it seems to me like it works as designed (if the form POSTs data). Just make sure that you process the form variables if the query string is missing.

Alek Davis
It uses POST, but when I do a refresh of the URL from the address bar in Fox, it reloads the page from the URL, which doesn't have the querystring and doesn't do a form post. Is there a way to force it to do a form post when I refresh like that?
Caveatrob
Are you saying that the page is refreshed from cache? If so, make sure that you follow these instructions: http://support.microsoft.com/kb/234067.
Alek Davis
+1  A: 

It sounds like the problem you're having is loss of some essential parameters to your page when posting. In ASP there are two primary methods of passing parameters, in the url string via GET or from a form POST. The former passes you values in the QueryString dictionary while the latter gives them to you in the Form dictionary. Fortunately for you it is possible to accept a parameter that exists in EITHER dictionary by looking to Request object:

Request["a"] will find a regardless of being in Request.QueryString["a"] or Request.Form["a"].

This will help you in your current dilemma because you can simply write your querystring parameters to your Form on initial load of the page as <input type="hidden" fields. On subsequent posts your Request["a"] search for your parameters will find them regardless of being passed in the URL (on initial load) or via post on subsequent calls.

Tahbaza
+1  A: 

The problem was that I was going into the Firefox address bar and pressing Enter. This caused the URL to reload (and of course it didn't have the querystring after it reposted). So -- lesson is to do a check of the incoming vars and form vars to see if the page has been manually refreshed I suppose...

Caveatrob
Well, as one could expect, it had nothing to do with refreshing. Pressing [enter] on the address bar has nothing to do with refresh or reload - though you could read it as "reloading" it's better to think of it as just "fresh load".
Cawas