0

I have stuck in a satiation and found no work around since last couple of hours, I have a form html stored in a string in VB.NET.

Dim form as string = <form id="PostForm" name="PostForm" action="https://www.example.com" method="POST"><input type="hidden" name="1" value="1"><input type="hidden" name="2" value="2"></form>

and then I am adding a script pro-grammatically in this string

form += "<script>PostForm.submit();

on a button click I generate this form and then assign this to a literal control like

Page.Controls.Add(New LiteralControl(form))

It submits the form and redirects to desire site example.com, I need to clear that literal control before redirecting from my page, because once form is added in html and user press back button of browser it renders the form again and submit the form specially in IE.

Shaohao
  • 3,471
  • 7
  • 26
  • 45
Sohail Hameed
  • 978
  • 2
  • 9
  • 25

1 Answers1

0

Consider using an intermediary "processing" page, which redirects to a results page. Otherwise known as Post/Redirect/Get. This is the standard way to prevent reloading a form through the Back button or refreshing the page.

E.g.

Your form action goes to http://www.example.com/processing. Once the form has processed the information, it redirects to http://www.example.com/results.

dajo
  • 187
  • 10
  • For intermediary page i need to redirect that page and then process form redirection from there, in that case also when user press back button from www.example.com it will back to that intermediary page. – Sohail Hameed Dec 31 '15 at 04:54
  • The solution here may assist for the reload issue - http://stackoverflow.com/questions/5381162/post-redirect-get-with-asp-net. It suggests using a querystring value to check if it's a postback or not. – dajo Dec 31 '15 at 11:35