redirect to current page in ASP.Net

C#asp.netRedirect

C# Problem Overview


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?

C# Solutions


Solution 1 - C#

Why Server.Transfer? Response.Redirect(Request.RawUrl) would get you what you need.

Solution 2 - C#

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionFabianoView Question on Stackoverflow
Solution 1 - C#epitkaView Answer on Stackoverflow
Solution 2 - C#kervinView Answer on Stackoverflow