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

5

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.

c#
asp.net-mvc
iis
asked on Stack Overflow Nov 20, 2015 by Johan Vergeer • edited May 23, 2017 by Community

5 Answers

0

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>
answered on Stack Overflow Nov 20, 2015 by kepler
0

I finally figured it out. All I had to do was change the url in RouteConfig.cs

from
url: "{controller}/{action}/{name}/{id}"
to
url: "{controller}/{action}",

answered on Stack Overflow Nov 20, 2015 by Johan Vergeer
0

This is a quick solution for quick app testing purposes and not intended for solving the root cause - not MVC:

answered on Stack Overflow Nov 14, 2016 by usefulBee
0

Here's what resolved my specific problem:

From Visual Studio, right click on the Website Project > Properties > Web > Select "Specific Page" > Browse > Select the Default page.

If you're using MVC 5 or higher, make sure that you remove move ".cshtml" and remove the Views directory. For example, the directory will show as Views/ControllerName/Index.cshtml. Remove Views so it shows as ControllerName/Index

answered on Stack Overflow Aug 26, 2017 by Auguste • edited Aug 26, 2017 by Auguste
0

My problem went away once I added a specific map route to RouteConfig.cs in the App_start folder

'routes.MapRoute("Buy lands", // string name "BuyLands/Index", // string Url new { controller = "BuyLands", Action = "Index" });

// controller name is BuyLands'

answered on Stack Overflow Oct 14, 2019 by Sam Patirage

User contributions licensed under CC BY-SA 3.0