Johan Vergeer Johan Vergeer - 18 days ago 31
C# Question

ASP.NET MVC5 The webserver is not configured for the requested URL, and directory browsing is not enabled on the server

I have an issue with loading the pages from a MVC5 application.

I have this software installed and used:


  • Windows 10

  • Visual Studio Enterprise 2015

  • Microsoft IIS 10.0 Express

  • MVC 5 with Entity Framework



Until now everything worked fine and I was able to display the website.
After creating a model and after that a controller using the entity framework I got this error message.

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:2063/
Physical Path c:\users\johan\documents\visual studio 2015\Projects\MvcMovie2\MvcMovie2
Logon Method Anonymous
Logon User Anonymous
Request Tracing Directory C:\Users\johan\Documents\IISExpress\TraceLogFiles\MVCMOVIE2


So first I started with the suggestions the error message is giving me.

These both worked fine.

- cd into the IIS Express install directory

-
appcmd set config /section:system.webServer/directoryBrowse /enabled:true


Then I tried to run this command:

appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true


Where I replaced
["SITE_NAME"]
with:

-
["SITE_NAME"]


-
["localhost"]


-
["MovieDb2"]


-
"MovieDb2"


-
[MovieDb2]


-
MovieDb2


None of them worked and I got an error message:

ERROR ( message:Cannot find SITE object with identifier ["SITE_NAME"]


I have been able to find a lot of documentation, but that all goes back to
.ASPX
format and older versions of IIS Express.

In Visual Studio I right clicked on one of the index.cshtml files of the application and clicked "Set as start page"

This didn't work, even after a rebuild.

Next I found some information that you would have to make some changes in IIS manager. I have searched a lot, but I am not able to find IIS manager.

Even using this link: https://msdn.microsoft.com/nl-nl/library/bb763170.aspx

The command
inetmgr
only returns an error.

To Web.config I added this code:

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>


That didn't solve the problem either.

After that I followed the steps from this page: HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory

But there I also have to get into the IIS manager, which I am not able to find.

I really hope someone has a solution for this.

Thanks in advance.

Answer

your root directory is empty?(index.html,index.aspx vb.) and I think Your project web.config default document property is not set.

Directory Browse Web.config properties

    <configuration>

  <location path="special_directory_name_here">
   <system.webServer>
    <directoryBrowse enabled="true" />
   </system.webServer>

  </location>
</configuration>

Please configure to your project default route settings, because your default route settings, is not redirect to controller.

Change Default route settings

http://blogs.msdn.com/b/prakasht/archive/2013/08/08/change-the-default-route-in-asp-net-mvc.aspx

Default Document Property web.config

<configuration>
   <system.webServer>
    <defaultDocument>
        <files>
            <add value="index.php" />
        </files>
    </defaultDocument>
   </system.webServer>
</configuration>
Comments