Can we have multiple AcceptVerbs attribute for a public controller method?

 Posted by Sheonarayan on 3/27/2012 | Category: ASP.NET MVC Interview questions | Views: 97654 | Points: 40
Select from following answers:
  1. Yes
  2. No
  3. Yes, separated by comma
  4. Yes, separated by colon
  5. All Above

Show Correct Answer

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Neha275 on: 1/6/2015 | Points: 10
Above answer is wrong
We can used Multiple AcceptVerb
[AcceptVerb(HttpVerb.Get | HTTPVerb.Post)]
Public ActionResult ContactUs()

If You using Shorthand of AcceptVerb i.e. HTTPPost or HTTPGet then you can't used multiple AcceptVerb.
Posted by: Sachcharit on: 3/6/2016 | Points: 10
The compiler throws an "Duplicate 'AcceptVerbs' attribute" error if we have multiple attributes on an action method. The correct way to include multiple verbs is by ORing the different verbs together as specified by Neha275 in the above answer.

public ViewResult List(string category, int page = 1)

Login to post response