0

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?

OJ Raqueño
  • 4,471
  • 2
  • 17
  • 30
  • 1
    Did you try adding <`directoryBrowse enabled="true"` /> in the web.config? Check this question http://stackoverflow.com/questions/15816924/http-error-403-14-forbidden-the-web-server-is-configured-to-not-list-the-conte – Spock Nov 24 '13 at 21:22
  • Thanks Spock. I actually decided to use the template and remove/change some items instead of just starting from scratch. Upvoted anyway. – OJ Raqueño Nov 29 '13 at 07:03

0 Answers0