我刚换了笔记本电脑。我正在移动我在 MVC 4 中完成的旧项目,并在 Visual Studio 2012 中完成。我的新笔记本电脑中当前的 Visual Studio 是 2017 版。
当我想调试我的 MVC 应用程序时出现问题。运行调试后出现此错误:
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.
我从未将我的应用程序设置为在目录浏览器中列出。我的应用程序是一个 MVC 应用程序,它将运行 global.asax 并重定向到我的主页。
我该如何解决这个问题?
最佳答案
启用目录浏览。
将其保存到您的 Web 配置文件中,然后重命名添加 value="pagename.aspx"
<system.webServer>
<defaultDocument>
<files>
<add value="yourpage.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
或
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
您还可以从 IIS 启用目录浏览
- 打开命令提示符,然后转到计算机上的 IIS Express 文件夹。例如,在命令提示符下转到以下文件夹:C:\Program Files\IIS Express
键入以下命令,然后按 Enter 键:
appcmd 设置配置/section:system.webServer/directoryBrowse/enabled:true
关于C#MVC : Cannot Debug in IIS Express,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47746632/