redirect to current page in ASP.Net
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.
精彩评论