I'm getting the following error when running our ASP.NET Web API project on our production server.
403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.
Looking at the IIS 7.0 error logs the underlying error is
403.14 - Directory listing denied.
I have configured the production server so it has the same settings as the staging server (which works). The authentication, modules, authorization, permissions etc are all identical.
Following a suggestion in this thread 403 - Forbidden: Access is denied. ASP.Net MVC I have managed to get it working by adding runAllManagedModulesForAllRequests="true" to my web.config file.
<modules runAllManagedModulesForAllRequests="true">
Whilst this works I don't see this as a long term solution as it will cause unnecessary load on the server.
So it seems to indicate that something isn't getting loaded that should be getting loaded.
Causes of 403 ForbiddenOften, HTTP 403 forbidden errors are caused by an access misconfiguration on the client-side, which means you can usually resolve the issue yourself. A common cause of these errors is the file or folder permission settings, which control who can read, write, and execute the file or folder.
In my case, someone deleted default Asp Net MVC Home/Index route in RouteConfig.
After placing this code back to the RouteConfig.cs in RegisterRoutes method the problem was gone.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
In case it helps anyone my issue was my publish options set to "Allow precompiled site to be updatable" and I was missing the file "PrecompiledApp.config" in my deployed API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With