The Web server is configured to not list the contents of this directory. asp.net vs 2012 error?
Have you tried setting the following within your web.config file :
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
The Web server is configured to not list the contents of this directory
The keyword in the error is list.
That sounds more like you do not have a default document
set up. If you don't have one, nor don't request a specific document (e.g. http://www.foobar.com/
or http://www.foobar.com/foo.html
respectively) IIS will not "know" what to "serve" to the browser nor will it, nor should you expect it to, list the contents of that directory (instead).
See: Microsoft Support: Error 403.14
A Short Story Of A Lost Controller, And A Happy Ending
Let's say you have a controller called Data
, in the project file /Controllers/DataController.cs
. You can access it just fine via http://yoursite.com/data
, which is handled by the DataController.Index
action method.
Then, somehow, it breaks, and you start getting "The Web server is configured to not list the contents of this directory" when you visit this URL. Strangely, visiting /data/index
still works! You try all the suggestions found online to make this work but can't seem to do it. What could it be?
Perhaps you ought to think about what the error means. It says that when you visit /data
, it finds a directory there, but you aren't allowed to see the files in it. Setting aside the fact that your routing doesn't seem to work and it should, could there actually be a directory there?
Yes, there could! In your web project, you cleverly added folder /Data
! This is a physical folder that takes precedence in the server's static routing rules (since you didn't rewrite those so physical files would be looked at after managed virtual paths).
The solution is thus to rename the folder, or rename the controller, one or the other. This will fix your problem quite speedily and you may then proceed on your merry way coding long into the night to the enveloping strains of techno Spanish mandolin trance music, with your trusty cat snoozing on your foot and the cold beverage of your choice beading up on the desk next to you!