如何在asp.net mvc中重定向到相同的路由(来自请求的地方)

Omu*_*Omu 6 asp.net-mvc asp.net-mvc-2

我正在通过部分视图发布一个表单,该表单通过Html.RenderAction表单发布后重定向到请求所在的同一路径.

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

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

谁知道怎么做?

Cas*_*nge 2

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

return Redirect(HttpContext.Request.UrlReferrer.OriginalString);
Run Code Online (Sandbox Code Playgroud)