C#MVC : Cannot Debug in IIS Express

标签 c# asp.net asp.net-mvc visual-studio asp.net-mvc-4

我刚换了笔记本电脑。我正在移动我在 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/

相关文章:

javascript - 有没有办法通过在 url 中使用 div id 来更改事件元素?

c# - 将纳秒转换为日期时间

c# - GridView 选择

asp.net - 有哪些选项可用于跨子域共享数据?

c# - 如何使 Razor View 引擎使用 C# 6.0

javascript - DatePicker 日期错误地绑定(bind)到 textbox-1 ?提供 fiddle

c# - mvc 中的强类型 web api 路由端点

asp.net-mvc - Azure 上的 Web 应用程序首次加载缓慢

c# - SqlDependency - 如何解释 SqlNotificationEventArgs 属性?

c# - 为什么 Console.Readline() 对其允许的文本长度有限制?