你如何重定向到使用POST谓词页?

问题描述:

当你调用 RedirectToAction 控制器内,它会自动重定向使用一个HTTP GET。我如何明确告诉它使用一个HTTP POST?

When you call RedirectToAction within a controller, it automatically redirects using an HTTP GET. How do I explicitly tell it to use an HTTP POST?

我有同时接受GET和POST请求的动作,我想能够 RedirectToAction 使用POST,并将其发送一些值。

I have an action that accepts both GET and POST requests, and I want to be able to RedirectToAction using POST and send it some values.

这样的:

this.RedirectToAction(
    "actionname",
    new RouteValueDictionary(new { someValue = 2, anotherValue = "text" })
);

要使用HTTP POST而不是GET发送

我要的 someValue中 anotherValue 值。有谁知道如何做到这一点?

I want the someValue and anotherValue values to be sent using an HTTP POST instead of a GET. Does anyone know how to do this?

HTTP不支持重定向到使用POST的页面。当您重定向某处时,HTTP位置头告诉浏览器到哪里去,和浏览器发出的该页面的GET请求。你可能不得不只写code,页面才能接受GET请求,以及POST请求。

HTTP doesn't support redirection to a page using POST. When you redirect somewhere, the HTTP "Location" header tells the browser where to go, and the browser makes a GET request for that page. You'll probably have to just write the code for your page to accept GET requests as well as POST requests.