Preventing Postdata when clicking refresh button

  • Thread starter Thread starter Navaneet
  • Start date Start date
N

Navaneet

Hi,

Can anyone tell me how to prevent some particular POST DATA when
refresh button (F5) clicked on server side(vb.net).


Thanks
Kumar N
 
Kumar,

What do you mean you want to prevent some particular post data? What
are you trying not to do?
 
Yes, i want to prevent only when refresh button get clicked.

Following is scenario where i am digging

1. There is xml file (Namely a.xml) which contains all the field
including hidden field.
2. There is a aspx file (Namely a.aspx) which having only vb.net code.
Depending on need it will parsing xml data on browser.
3. From some page a.aspx page get in action containg post data.
4. Now from a.aspx page calling a javascript function, at there we had
set a hidden attribute value to 1 (which is define in a.xml file) and
submitting the form which contains that hidden attribute value.
5. So depending on that attribute value a.aspx parse the a.xml.
6. Now when i refresh button (F5) press step-4 and 5 should be called.

My need, step-4 will not called when refresh button hit, it will
called only when step-4 explicitly called.

Please tell what i have to do to resolve this.

Thanking You a lot !
: Kumar N

Kumar,

What do you mean you want to prevent some particular post data? What
are you trying not to do?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Can anyone tell me how to prevent some particular POST DATA when
refresh button (F5) clicked on server side(vb.net).
Thanks
Kumar N- Hide quoted text -

- Show quoted text -
 
This may not be the most elegant idea, but it's the first that comes to mind.
1) the first time, set a Session Item that will be used to identify that the
page has already been posted (or whatever it is that you need to prevent
happening more than 1x)
2) On each subsequent Page_Load, you would check for the presence of the
Session Item from #1 above, and disallow the action if it is there.
-- Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



Navaneet said:
Yes, i want to prevent only when refresh button get clicked.

Following is scenario where i am digging

1. There is xml file (Namely a.xml) which contains all the field
including hidden field.
2. There is a aspx file (Namely a.aspx) which having only vb.net code.
Depending on need it will parsing xml data on browser.
3. From some page a.aspx page get in action containg post data.
4. Now from a.aspx page calling a javascript function, at there we had
set a hidden attribute value to 1 (which is define in a.xml file) and
submitting the form which contains that hidden attribute value.
5. So depending on that attribute value a.aspx parse the a.xml.
6. Now when i refresh button (F5) press step-4 and 5 should be called.

My need, step-4 will not called when refresh button hit, it will
called only when step-4 explicitly called.

Please tell what i have to do to resolve this.

Thanking You a lot !
: Kumar N

Kumar,

What do you mean you want to prevent some particular post data? What
are you trying not to do?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




Can anyone tell me how to prevent some particular POST DATA when
refresh button (F5) clicked on server side(vb.net).
Thanks
Kumar N- Hide quoted text -

- Show quoted text -
 
Navaneet said:
Can anyone tell me how to prevent some particular POST DATA when
refresh button (F5) clicked on server side(vb.net).

Try search for Token pattern (or Synchronizer Token pattern).

Arne
 
Arne said:
Try search for Token pattern (or Synchronizer Token pattern).

Keyword: "idempotent".

Make the transaction idempotent. Token pattern is a standard way to do that.
 
Lew said:
Keyword: "idempotent".

Make the transaction idempotent. Token pattern is a standard way to do
that.

It is an artificial way of making it idempotent in cases where
it can not be done natural.

Arne
 
It is an artificial way of making it idempotent in cases where
it can not be done natural.

It is a very powerful technique, and I was elated when I first read of it.
I'm not quite sure what you mean by "artificial", but I don't guess that you
mean that as a pejorative.

A couple of years back I had a rash of managers who wanted to mandate that the
team "disable the back button" or "disable the refresh button", a truly bad
idea and one that always created more problems than it solved. The Token
Pattern gave us the goal we wanted - that repeated submissions would not cause
repeated transactions. It eliminated the problems caused by trying to control
browser behavior from the server, not to mention it avoided breaking the
standard idiom that users expect of the back button.

The Token Pattern provide a straightforward, easily-implemented way to enforce
idempotency on our transactions.
 
Lew said:
It is a very powerful technique, and I was elated when I first read of
it. I'm not quite sure what you mean by "artificial", but I don't guess
that you mean that as a pejorative.

I mean that certain operations are natural idempotent.

If it fires off a SQL statement:
UPDATE tbl SET flag = FALSE WHERE id = 123
then you don't need to do anything in the app code.

If it fires off:
UPDATE tbl SET flag = NOT flag WHERE id = 123
then you need to use token pattern in your code to achieve
the same effect. You make a non natural idempotent operation
artificially idempotent.

Arne
 
Arne said:
I mean that certain operations are natural idempotent.

If it fires off a SQL statement:
UPDATE tbl SET flag = FALSE WHERE id = 123
then you don't need to do anything in the app code.

If it fires off:
UPDATE tbl SET flag = NOT flag WHERE id = 123
then you need to use token pattern in your code to achieve
the same effect. You make a non natural idempotent operation
artificially idempotent.

That is very illuminating, thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top