asp.net - 为从 Visual Studio 发布的 ASP.NET 项目启用目录浏览
问题描述
我正在尝试导入一个我知道有效的 ASP.NET 项目,并且我正在尝试在本地构建它。我在 Visual Studio 中导入了解决方案文件并继续并对其进行了清理和构建,一切正常。现在我正在尝试发布项目,一旦我这样做了,我点击了运行按钮,上面写着 IIS Express,我看到了以下内容
HTTP Error 403.14 - Forbidden
Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
如果我在 IIS 管理器中运行此应用程序,我知道如何通过单击项目、单击目录浏览并单击启用来解决此问题,但如果我从 Visual Studio 中运行它,我不知道如何解决此问题。
解决方案
要解决此问题,您可以尝试以下方法之一:
1)在web.config文件中设置如下代码:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
</system.webServer>
2)为您的项目设置默认页面:
<system.webServer>
<defaultDocument>
<files>
<add value="pagename.aspx" />
</files>
</defaultDocument>
</system.webServer>
如果您使用的是 MVC 站点,则设置默认路由。
推荐阅读
- javascript - 当他/她单击按钮时,将用户的电子邮件存储在不同的页面上
- python - 改变 xytext 以防止重叠注释
- cucumber - 通过 -Dcucumber.options 传递多个标签(或/和)不会触发我的测试
- excel - 三角形的 VBA 面积
- python - ValueError:无法将字符串转换为浮点数:'thal'
- windows - 创建新文件后资源管理器中的 IShellView::SelectItem
- python - 如何从 Python 中的多个串行输入中读取?
- python - 'ImportError: DLL load failed': import seaborn failed / 仅适用于 conda root 作为 jupyter notebook 中的内核
- php - 内爆数组并将动态数据插入mysql数据库
- ios - RevenueCat - 为什么我得到:错误域 = SKErrorDomain 代码 = 2“无法连接到 iTunes Store”