I have created an api controller with attribute routing:
[RoutePrefix("fonts")]
public class InfoController : ApiController
{
[Route("")]
[HttpGet]
public IHttpActionResult GetSomeInfo()
{
return Ok(new { Name = "Some name" });
}
}
And I have a folder in the project root called "fonts".
when I am trying to request:
GET /fonts
IIS throws an error:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
How can I fix this to call the controller action?
UPDATE: Here is the web api config class, which is the default web api configuration created by VS.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}