简体   繁体   中英

If I do not specify [httpGet] or [httpPost] for the action method , what will be the rule for calling it

Previously as many articles mentioned that HttpGet is the default http method. For example if I have the following action method inside asp.net mvc web application, without any [httpGet] or [HttpPost]:-

Public ActionResult TestMethod(int I =0)

So I thought that this action method will be defined as Get action method, and will NOT be reachable if I send Posr request as follow “POST http://severname/test/TestMethod?i=1” .

But seems that my action method will be available for both Post & Get requests, when I do not specify any http method. So as I know that HttpGet is the default , but seems this is not the case? Or I am missing something about what does httpGet is the default mean? Can anyone advice please? Thanks

What I understand, By default It accept both type of request whether it is GET or POST. but when a action method is decorated with either [httpGet] or [httpPost] attribute then the action method accepts only those request method which define by attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM