GET和POST在ASP.NET MVC相同的控制器操作 [英] GET and POST to same Controller Action in ASP.NET MVC
本文介绍了GET和POST在ASP.NET MVC相同的控制器操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想有一个动作响应双方获取和帖子。我尝试以下
I'd like to have a single action respond to both Gets as well as Posts. I tried the following
[HttpGet]
[HttpPost]
public ActionResult SignIn()
似乎没有工作。有什么建议?
That didn't seem to work. Any suggestions ?
推荐答案
这是可能的使用AcceptVerbs属性。其有点冗长,但更灵活。
This is possible using the AcceptVerbs attribute. Its a bit more verbose but more flexible.
[AcceptVerbs(HttpVerbs.Get|HttpVerbs.Post)]
public ActionResult SignIn()
{
}
更多关于<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.acceptverbsattribute.aspx\">msdn.
这篇关于GET和POST在ASP.NET MVC相同的控制器操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文