ASP.NET Refresh Problem

  • Thread starter Thread starter wright
  • Start date Start date
W

wright

hello, i have a problem in refreshing a page. the problem happens when i
click a button that does a certain action in a web page, such as inserting a
record into the database, if now i refresh the page (press f5), the action
repeats itself and another identical record is inserted too.
i discovered that the button_click event is called when i refresh the page.
so the problem is that when i refresh the page, the last action that i have
done on the page is refired.
if anybody can tell me how to solve this problem ill be thankfull...
 
You can't exactly solve it. What you can do is to handle it on the server.
For example, you could set a Session variable when the insert occurs, and
check it before doing the insert. If the Session variable is there, you know
the record has been inserted already. Of course, you have to remove the
Session variable at some point in order to do another insert. But of course,
there are ways of doing that as well. There are other solutions as well. How
you handle it is up to you, based upon the functionality of your page, and
your creativity.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
The problem is that when you press F5 IE sends excatly same info to the
server.
And server can not distinguish between first request and second.

The easiest thing is to redirect to the page (it could be the same page).

George.
 
Back
Top