Redirect user to source page

I have an edit page that is used from various sources. After editing, I would like to redirect the user to the original page. I used to use an identifier (specified as a parameter) and Action (hardcoded) to redirect the user to a specific page, but problems arise when many pages can access the same edit page.

Are there any suggestions for resolving this situation? Should I store the full URL and pass it as a parameter? Are there any known issues with this (line length, etc.)?

+4
source share
2 answers

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

+2
source

I use something like this when I need a link.

var referrer = HttpContext.Request.UrlReferrer; if (referrer! = null) {return Redirect (referrer.ToString ()); } return RedirectToAction ("Index");

+2
source

Source: https://habr.com/ru/post/1300617/


All Articles