Tx3
Tx3

Reputation: 6916

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.)?

Upvotes: 4

Views: 806

Answers (2)

Kevin McPhail
Kevin McPhail

Reputation: 729

I use something like this when i i need the referring page.

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

Upvotes: 2

Branislav Abadjimarinov
Branislav Abadjimarinov

Reputation: 5131

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

Upvotes: 2

Related Questions