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

I have a problem loading pages from an MVC5 application.

I have this software installed:

  • Windows 10
  • Visual Studio Enterprise 2015
  • Microsoft IIS 10.0 Express
  • MVC 5 with Entity Framework

So far, everything has been working fine and I was able to display the website. After creating the model and after that, the controller using the entity structure received 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 sentences that the error message gives me.

Both of them worked great.
 - cd to the IIS Express installation 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

["SITE_NAME"] : - ["SITE_NAME"]
- ["localhost"]
- ["MovieDb2"]
- "MovieDb2"
- [MovieDb2]
- MovieDb2
, :
ERROR ( message:Cannot find SITE object with identifier ["SITE_NAME"]

, .ASPX IIS Express.

Visual Studio index.cshtml " "
, .

, IIS. , IIS.
: https://msdn.microsoft.com/nl-nl/library/bb763170.aspx
inetmgr .

Web.config :

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

.

: HTTP 403.14 - - ,

IIS, .

, - .
.

+4
5

? (index.html, index.aspx vb.), , web.config .

Web.config

    <configuration>

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

  </location>
</configuration>

, , .

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

web.config

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

, , . , , URL- RouteConfig.cs


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

0

:

Visual Studio -a > a > > " " > p > .

MVC 5 , , ".cshtml" Views. , Views/ControllerName/Index.cshtml. , _/

0

, RouteConfig.cs App_start

'rout.MapRoute ("Buy land", // string name "BuyLands / Index", // string URL new {controller = "BuyLands", Action = "Index"});

// BuyLands' controller name

0
source

Source: https://habr.com/ru/post/1649865/


All Articles