简体   繁体   English

RedirectToAction-如何返回2页?

[英]RedirectToAction - how to go back 2 pages back?

At the end of my ActionResult method I have 在我的ActionResult方法的最后,我有

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

which redirect to the previous page. 重定向到上一页。 Is there any way to redirect it to two or three pages back? 有什么办法可以将其重定向回两页或三页?

One way is to have a list of four Uri s stored in Session and for each request, to push away the olders and push current Uri - Request.RequestUri . 一种方法是将四个Uri的列表存储在Session并且对于每个请求,将较旧的Uri推开,并推入当前的Uri- Request.RequestUri

When going back just choose one of the oldest within the stored Uris. 返回时,只需选择存储的Uris中最旧的之一。

However, you can consider using Html5 history API, as indicated here . 但是,你可以考虑使用HTML5历史API,指示在这里

I think the answer you looking for can be found here. 我认为您可以在这里找到所需的答案。

How to use RedirectToAction to redirecto to a position in the page? 如何使用RedirectToAction重定向到页面中的某个位置?

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM