I'm trying to use the attribute-based routing in Web Api 2. So I added this:
public class PropertyApiController : ApiController
{
[Route("properties")]
public IEnumerable<Property> GetAll()
{
// return properties
}
}
I also have this in WebApiConfig
:
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
From my understanding, it should work when I type something like:
http://localhost:3648/properties/
(http://localhost:3648
is the IIS express url set in the project properties.)
But when I try to do that I get the error message:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Whereas I was expecting some kind of json. Any ideas?