重定向到邮政法/动作 [英] Redirect to Post Method/Action
本文介绍了重定向到邮政法/动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须接受POST一个ActionResult,但有一个变通,我从一个控制器重定向到包含此POST方法/措施?另一个控制器
这里是我重定向到方法的签名;
[ValidateAntiForgeryToken]
[交易]
的[AcceptVerbs(HttpVerbs.Post)
公众的ActionResult编辑(支付款项,PaymentApplication paymentApplication,串;交换,布尔手册,INT firstPaymentId,诠释?exchangeEventId,布尔addOnly)
{}
解决方案
您不能使用 RedirectToAction
来调用一个POST方法。针对您的特殊需要,只需新的控制器,并直接从其他控制器调用该方法,无论传递的参数。
VAR控制器=新YourControllerWithMethodToCall();
controller.Edit(付款等);
I have an ActionResult that accepts POST, however is there a work around for me to redirect from a controller to another controller containing this POST method/action???
Here is signature of the method I am redirecting to;
[ValidateAntiForgeryToken]
[Transaction]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Payment payment, PaymentApplication paymentApplication, string exchangeId, bool manual, int firstPaymentId, int? exchangeEventId, bool addOnly)
{
}
解决方案
You cannot use RedirectToAction
to call a POST method. For your specific need, just new the controller and call the method directly from the other controller, passing whatever the parameters.
var controller = new YourControllerWithMethodToCall();
controller.Edit(payment, etc...);
这篇关于重定向到邮政法/动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文