Hi, I donβt have a coding solution for you, but rather a logical solution . Try it, it can help you, it helped me
I had the same problem when I used "ShoppingCart? AddToCart = 1 & ....." in my URL (GET Variable) as a way to find out that the user wants to add products to the cart, and every time I refresh the page , the same product was added again and again
My way of working, when I received the AddToCart request , was the first to execute a method that would add the product to the basket and then execute another method that would display the contents of the basket (THIS WAS A PROBLEM RIGHT HERE)
I changed the logic a bit
Now that I get the same AddToCart request , I execute the same first method to add content to the cart
BUT
Now, instead of the second way to display the contents of the basket, I use the heading ("Location: ShoppingCart? ViewCart = 1")
This means that after executing the first method that adds content to the cart, I make a ViewCart Request on the page of my shopping cart, now every time I make an AddToCart request> it correctly adds the contents to the cart, and after that, when I try refresh the page to try to replicate the AddToCart request , I always get a ViewCart request, and the Page just shows the contents of the cart, and does not add more content to the cart.
The trick here is that every time I get "ShoppingCart? AddToCart = 1 & ....." , I execute the Add function and the header function so that I end up with the display of "ShoppingCart? ViewCart = 1" in URL, not in the original "ShoppingCart? AddToCart = 1 & ....."
Now, even if some people try to refresh the page or return to the page using the "Back" button in the browser, they always end the query "ShoppingCart? ViewCart = 1" , they never see "ShoppingCart? AddToCart = 1 & ....." in url
as I said, I don't have a coding solution, but rather from a logical solution
Hope this helps