Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browser dependent server-side code execution !?

Status
Not open for further replies.

Spork52

Programmer
Nov 20, 2007
134
US
Didn't really know where to post this.

I've got an ASP shopping cart with delete links next to each item in the cart. When the link is clicked the item is deleted from the cart and a record that keeps track of the number of items in the cart is incremented down by 1. Works fine, except in FIrefox which increments down by 2.

How is this possible? The code is all server-side vbScript and T-SQL. The update is somehow getting executed twice. I checked the number of items before and after the update and it is incrementing by one, but the next time I click a delete link, the numbers are off by 1. E.g.: Start with 10 items in cart. Click to delete one. The code says that there were ten and that there are now 9. So far so good. So, click to delete another item. Now the code says there were 8 and that now there are 7.
 
I bet if you look in the server activity logs that the browser is actually sending two HTTP Requests in quick succession so it is causing the page to run twice.

I’d also wonder if it is the browser’s fault or some plug-in… does it happen on a fresh empty install of firefox?

Finally if you are sure it is a problem with a particular browser you could always examine the [tt]Request.ServerVariables[/tt] collection to pick out a unique string that will help you identify Requests from the problem browser so that you can use different logic for that oen.


 
Thanks, I think you are right about the browser sending the request twice. Not a good thing for a browser to do. I'm using fresh installs of Firefox with no add-ons on two computers. I temporarily solved the problem by doing a redirect back to the same page instead of having the page load after the code executed. But if reloading the page twice causes a problem, then my code is not so good, so I'll be doing some rewrites.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top