So, this is a simple one. I have done this in the past. But, it seems that I am missing something.
WebApiConfig.cs
public static void Register(HttpConfiguration config)
{
// Attribute routing.
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
Global.asax.cs
protected void Application_Start(object sender, EventArgs e)
{
GlobalConfiguration.Configure(WebApiConfig.Register);
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
SomeController.cs
[RoutePrefix("api")]
public class SomeController: ApiController
{
[Route("some")]
[HttpGet]
private HttpResponseMessage GetSome(HttpRequestMessage request)
{
...
}
}
Now, when I call: http://localhost:54699/api/some, I get the following 404:
{ "Message": "No HTTP resource was found that matches the request URI 'http://localhost:54699/api/some'.", "MessageDetail": "No type was found that matches the controller named 'some'." }
Folder structure:
