Undgå event handler eksekvering ved page refresh

A simple solution is to Response.Redirect back to the same page after the INSERT command is called.  This will call up the page without transmitting any post headers to it.  Using Request.Url.ToString() as the first parameter of Response.Redirect will cause both the URL and the page’s querystring to be included in the redirect.  The use of false as the second parameter will suppress the automatic Response.End that may otherwise generate a ThreadAbortedException.  A disadvantage of this approach is that any ViewState that had been built up will be lost.

this.Response.Redirect(this.Request.Url.ToString(), false);

Se her for flere løsninger.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.