0

At the end of my ActionResult method I have

return RedirectToAction(Request.UrlReferrer.ToString());

which redirect to the previous page. Is there any way to redirect it to two or three pages back?

Zet
  • 571
  • 3
  • 13
  • 31

2 Answers2

1

One way is to have a list of four Uris stored in Session and for each request, to push away the olders and push current Uri - Request.RequestUri.

When going back just choose one of the oldest within the stored Uris.

However, you can consider using Html5 history API, as indicated here.

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • In general, relying on ASP.NET Session is not considered good practice for an MVC app. I'm not going to downvote because the concept is sound and the history link is useful, but there's probably a better place to put this information if the OP does decide to store it on the server. – smartcaveman Jun 12 '16 at 07:11
0

I think the answer you looking for can be found here.

How to use RedirectToAction to redirecto to a position in the page?

Hope it helps.

Community
  • 1
  • 1
Twahanz
  • 204
  • 1
  • 15