allowing no postbacks if the user does a browser refresh

Greetings,

What I am trying to do is prevent the form from doing a postback on a browser refresh after the user has already submitted the form. Is this possible to do?
JDEE8297Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Göran AnderssonCommented:
No, that is not possible. The browser can always do a refresh, and that sends another request to the server with the same data as the last request.

What you can do is to save some data on the server, so that you can detect if it's a repeating request that is coming to the server.

For example saving the time when a reuqest is accepted in a session variable and also put the value in a hidden field in the form, and only accept requests where the hidden value corresponds with value in the session varable.
0
JDEE8297Author Commented:
trying to avoid session variables if at all possible. You see this could live in a web farm and the use of session variables (although possible) is not desirable in this application. So I am trying to come up with a work around for it.

Your solution with the hidden form field sounds good,  but again I have some examples using session variables and view state and although they seem to work. they do seem like a hack. Tis amazing that this problem has been resolved in the framework, because I know that this is not thefirst time I have ran into it.

0
Ted BouskillSenior Software DeveloperCommented:
In regard to a farm, you should consider using the ASP.NET session state service or a SQL data source for sessions.  Building web applications on a farm without sessions restricts your choices.  OR, if you setup your farm with Windows NLB (Network Load Balancing) you can create sticky sessions.  In other words is UserA starts a session on ServerA, they will always return to ServerA.  It's called 'Affinity'

By the way, here is an article that solves your problem: http://www.codeproject.com/KB/cpp/BrowserRefreshASPdotNET.aspx
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

JDEE8297Author Commented:
tedbilly,

I know all about the use of asp.net session state and sql data for storing state or setting up NLB to do sticky sessions. the problem is that I have brought up all of these options for storing session, each one has been shot down because it involves using session objects.

So I was looking for something that didn't do session or anything like that. the link you gave looks promising and I will try that out at my work place tomorrow. I will let you know how it went.
0
Ted BouskillSenior Software DeveloperCommented:
I just wanted to be sure you were aware of your choices.  That wasn't clear in the question or previous comments.  Session objects can often be abused so many people go the opposite route and ban them.  Ulimately, you have to work with what you are given for requirements.

I've used a combination of cookies and hidden form values to eliminate sessions.  It is possible just a bit of a challenge.

I'm confident that link will do what you need.  Cheers
0
Göran AnderssonCommented:
You don't have to user a session variable, but you have to store the information on the server some way. Perhaps in a database?

The solution that tedbilly linked to doesn't work at all. You can't use a static variable to store user specific data in a web application. (I also left a message in the article explaining this.)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JDEE8297Author Commented:
thanks for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.