加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 如何在asp.net mvc中重定向到相同的路由(来自请

发布时间:2020-12-16 03:51:39 所属栏目:asp.Net 来源:网络整理
导读:我从部分视图发布一个表单,该表单通过 Html.RenderAction呈现,我希望在表单发布之后重定向到请求来自的相同路由. public ActionResult Index(){ return PartialView();}[HttpPost]public ActionResult Index(FormModel input){ ... return //Redirect to the
我从部分视图发布一个表单,该表单通过 Html.RenderAction呈现,我希望在表单发布之后重定向到请求来自的相同路由.

public ActionResult Index()
{
    return PartialView();
}

[HttpPost]
public ActionResult Index(FormModel input)
{
     ...
     return //Redirect to the same route
}

谁知道怎么做?

解决方法

您可以从Request对象中检索UrlReferrer:

return Redirect(HttpContext.Request.UrlReferrer.OriginalString);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读