[英]Redirect to Post Method/Action
我有一個接受POST的ActionResult,但是有一個工作可以讓我從控制器重定向到另一個包含這個POST方法/動作的控制器嗎?
這是我重定向到的方法的簽名;
[ValidateAntiForgeryToken]
[Transaction]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Payment payment, PaymentApplication paymentApplication, string exchangeId, bool manual, int firstPaymentId, int? exchangeEventId, bool addOnly)
{
}
您不能使用RedirectToAction
來調用POST方法。 根據您的具體需要,只需新建控制器並直接從另一個控制器調用該方法,傳遞任何參數。
var controller = new YourControllerWithMethodToCall();
controller.Edit(payment, etc...);
是的,你可以做到這一點
<% using (Html.BeginForm("Edit", "AnotherController", FormMethod.Post, new { id = "formNameHere" }))
{%>
//form content here
<input type="submit" Value="Post Me" id="PostMe">
<%} %>
在ActionNameParameter中,您可以編寫Action,在ControllerNameParameter中,您可以編寫您想要發布數據的controllername。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.