I have a problem.
WebApiConfig
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}",
defaults: new
{
id = RouteParameter.Optional,
api = "api",
namespaces = new string[] { "able.application.api" }
}
);
}
}
Global.asax
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
RouteConfig.RegisterRoutes(RouteTable.Routes);
GlobalConfiguration.Configuration.EnsureInitialized();
}
Controller
public class ContentModelController : ApiController
{
public ContentModelController()
{
}
[HttpPost, HttpGet]
public HttpResponseMessage Get(int? id)
{
return null;
}
}
The problem is: When I call get method, I get the following error.
CallUrl: http://localhost:54531/api/ContentModel/get?id=1
Please, help me.. :(
<Error> <Message> No HTTP resource was found that matches the request URI 'http://localhost:54531/api/ContentModel/get?id=1'. </Message> <MessageDetail> No type was found that matches the controller named 'ContentModel'. </MessageDetail> </Error>