Server.Transfer Refreshing Browser Problem

I

Ian Walsh

I have two pages in my project.

Page 1 has a command button that when it is clicked inserts a record
in a database and does a server.transfer to Page2.

The problem is, if I do a refresh when the browser gets to Page2, it
re-runs the insert code on Page1 resulting in two records being
inserted. I guess the whole point of Server.Transfer is that it all
happens server side.

I like using Server.Transfer, because I don't have to have query
strings and session variables obviously span the whole project. Is
there any way to stop this behaviour?
 
R

Richard K Bethell

Ian Walsh said:
I have two pages in my project.

Page 1 has a command button that when it is clicked inserts a record
in a database and does a server.transfer to Page2.

The problem is, if I do a refresh when the browser gets to Page2, it
re-runs the insert code on Page1 resulting in two records being
inserted. I guess the whole point of Server.Transfer is that it all
happens server side.

I like using Server.Transfer, because I don't have to have query
strings and session variables obviously span the whole project. Is
there any way to stop this behaviour?

Not really. Your browser still thinks it is at the old page, and is hitting
up the old page with a new request. F5 IE refreshes are very dangerous in
this context. The one nice thing about Response.Redirect() is that, despite
the round tripping, there is no risk of this sort of thing happening.

R.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top