How can I perform a redirect with Server.Transfer()
to the same page that is currently shown?
I want to have A cleared form after submit.
What other/better methods can I use to achieve the same?
Why Server.Transfer
? Response.Redirect(Request.RawUrl)
would get you what you need.
http://en.wikipedia.org/wiki/Post/Redirect/Get
The most common way to implement this pattern in ASP.Net is to use Response.Redirect(Request.RawUrl)
Consider the differences between Redirect and Transfer . Transfer really isn't telling the browser to forward to a clear form , it's simply returning a cleared form. That may or may not be what you want.
Response.Redirect() does not a waste round trip. If you post to a script that clears the form by Server.Transfer() and reload you will be asked to repost by most browsers since the last action was a HTTP POST. This may cause your users to unintentionally repeat some action, eg. place a second order which will have to be voided later.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.