【发布时间】:2015-11-20 13:44:25
【问题描述】:
我在从 MVC5 应用程序加载页面时遇到问题。
我已经安装并使用了这个软件:
- Windows 10
- Visual Studio 企业版 2015
- 微软 IIS 10.0 Express
- 带有实体框架的 MVC 5
到目前为止,一切正常,我能够显示该网站。 在创建模型和使用实体框架的控制器之后,我收到此错误消息。
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
所以首先我从错误消息给我的建议开始。
这两个都很好。
- cd 进入 IIS Express 安装目录
- appcmd set config /section:system.webServer/directoryBrowse /enabled:true
然后我尝试运行这个命令: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 Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory
但是我还必须进入 IIS 管理器,我无法找到它。
我真的希望有人对此有解决方案。
提前致谢。
【问题讨论】:
-
听起来 ASP.NET MVC 没有在 IIS Express 上正确注册,这很奇怪。您必须使用 Jexus Manager 等工具来检查应用程序池设置,以查看是否配置了 CLR 版本 4。
标签: c# asp.net-mvc iis