Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpGet Attribute not usable when including the System.Web.Mvc libraries

I am writing a Web API which differentiates between HttpGet and HttpPost request types. I just added the System.Web.Mvc and System.Web.Mvc.Ajax namespaces to the project, and my ability to define HttpGet and HttpPost disappears. It can't find the attributes anymore.

What's goin' on?

like image 494
Brian D Avatar asked Oct 25 '25 17:10

Brian D


1 Answers

Are you including both the System.Web.Http and System.Web.Mvc namespaces in the same file?

I can't think of a lot of good reasons why you would want to do that, but if you are, then you need to add the full namespace. See below for an example. Since both the Mvc and Http namespaces have a HttpGet and HttpPost, you need to specify which one to use.

HttpGet for Http and Mvc

like image 135
Mike Stonis Avatar answered Oct 28 '25 22:10

Mike Stonis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!