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

后端 未结 5 465
终归单人心
终归单人心 2021-01-05 16:46

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

I have this software installed and used:

  • Windows 10
  • Visual Studio Enterpris
相关标签:
5条回答
  • 2021-01-05 16:49

    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'

    0 讨论(0)
  • 2021-01-05 16:54

    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

    0 讨论(0)
  • 2021-01-05 16:59

    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>
    
    0 讨论(0)
  • 2021-01-05 17:07

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

    • Errors when the ASP.NET application starts at http://localhost:port#/

    • Works when the url changed to http://localhost:45269/HTMLPageName.html

    0 讨论(0)
  • 2021-01-05 17:14

    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}",

    0 讨论(0)
提交回复
热议问题