asp.net-mvc – ASP.NET MVC:具有POST Action参数的RedirectToAction

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – ASP.NET MVC:具有POST Action参数的RedirectToAction前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这个问题在这里被问到:

RedirectToAction with parameter

但是如果我有两个具有相同名称但参数不同的动作呢?如何重定向到POST条款操作而不是GET条款操作.

public ActionResult Terms() {
    //get method
}

[HttpPost]
public ActionResult Terms(string month,string year,int deposit = 0,int total = 0) {
    //process POST request
}

解决方法

不要害怕,实际上我可以直接调用方法,而不是使用RedirectToAction,如下所示:
return Terms(month,year,deposit,total);

代替:

return RedirectToAction("Terms",{month,total});
原文链接:https://www.f2er.com/aspnet/250267.html

猜你在找的asp.Net相关文章