Search code examples
asp.netasp.net-mvchttp-redirectreturn-path

Redirect user back to the original page


I have an edit page which is used from different sources. After editing I would like to redirect user to original page. Earlier I used ID (given as a parameter) and Action (hard-coded) to redirect user to certain page, but problems occurs when many different pages can access the same edit page.

Any suggestions how to handle this situation? Should I store complete URL and pass it as a parameter? Are there any known issues with that (string length etc.)?


Solution

  • You can use query string parameter "ReturnUrl" as you suggested or Request.UrlReferer.