开发者

Is it possible to make a redirection issuing POST verb in asp.net mvc?

I want to redirect to an action method of another controller such that the b开发者_如何学编程rowser issues POST instead of GET verb.

Is it possible to do that?


Well the nature of a "redirect" in HTTP terms is an instruction to the browser to perform a HTTP GET to a particular URL.

So, in HTTP terms - it's not possible.

However :)

Instead of doing RedirectToAction("ActionMethod", "Controller", new { param = value }), you could do return View("ActionMethod", value) which would pass the value as a key/value pair in the HTTP POST body, assuming ActionMethod is setup with [HttpPost], like so:

[HttpPost]
public ActionResult ActionMethod(string param) 
{

}

However, keep in mind that will not perform a redirect - it's like of the equivalent of a cross-page postback in ASP.NET Web Forms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜