'Extend ApiController
As the title suggests I want to extend the ApiContoller class to include some custom properties and helper methods but whenever I try to use it for a controller I get the message Multiple actions were found that match the request:
Example Code:
public class ExtendedApiController : ApiController {
public string SomeHelper() {
....
}
}
public class AccountController : ExtendedApiContoller {
public void Post (ModelObject obj){
string x = SomeHelper();
...Bunch of business logic
}
}
The Web Api seems to dislike me doing this for some reason or there is some other base method I need to override. The only other option I can see is tacking on extension methods to the ApiContoller but I'd like to avoid that if possible.
Any ideas?
Solution 1:[1]
ASP NET WebAPI uses convention before configuration, so it tries to find a method that begins with Get... for GET requests, Post... for POST requests and so on for PUT and DELETE.
So maybe you have 2 methods begining by Get..., Post..., Put... or Delete...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | polkduran |
