Reputation: 85785
I created a empty web api 2 project and created a default controller. When I try to go to my controller I get
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
Things you can try:
If you do not want to enable directory browsing, ensure that a default document is configured and that the file exists.
Enable directory browsing.
Go to the IIS Express install directory.
Run appcmd set config /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the server level.
Run appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true to enable directory browsing at the site level.
Verify that the configuration/system.webServer/directoryBrowse@enabled attribute is set to true in the site or application configuration file.
Detailed Error Information:
Module DirectoryListingModule
Notification ExecuteRequestHandler
Handler StaticFile
Error Code 0x00000000
Requested URL http://localhost:49886/api/default/
Physical Path C:\Users\Source\Repos\ospapi\OSP.Api\OSP.Api\
Logon Method Anonymous
Logon User Anonymous
Request Tracing Directory C:\Users\Documents\IISExpress\TraceLogFiles\OSP.API
More Information:
This error occurs when a document is not specified in the URL, no default document is specified for the Web site or application, and directory listing is not enabled for the Web site or application. This setting may be disabled on purpose to secure the contents of the server.
View more information »
My url: http://localhost:49886/api/default/
Upvotes: 0
Views: 6968
Reputation:
The problem is because your route is not properly set to call api. Make sure you have proper path with every method (eg. api/default/insert). Otherwise if you try to call direct controller it will show this error.
Upvotes: 1
Reputation: 136
Make sure that you have a controller with name default. Check the routes in WebApiConfig file
Upvotes: 0