Hello,
I need to detect when a user refreshing the page in the Page_Init event to stop them from executing the same code twice. What's the way to do this in ASP.NET
thanks
Hello,
I need to detect when a user refreshing the page in the Page_Init event to stop them from executing the same code twice. What's the way to do this in ASP.NET
thanks
Yes, the Page.IsPostBack
property:
Gets a value indicating whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.
Here's an article that talks about some different ways of dealing with this problem, though I'm not sure it matches 100% with your situation.
You can set cookie with short expiration time after first request on your site. Then you can simply check it and enlarge the cookie expiration.