ASP.NET MVC5未针对请求的URL配置Web服务器,并且未在服务器上启用目录浏览 [英] ASP.NET MVC5 The webserver is not configured for the requested URL, and directory browsing is not enabled on the server
问题描述
我在从MVC5应用程序加载页面时遇到问题。
I have an issue with loading the pages from a MVC5 application.
我安装并使用了这个软件:
I have this software installed and used:
- Windows 10
- Visual Studio Enterprise 2015
- Microsoft IIS 10.0 Express
- 带有实体框架的MVC 5
- Windows 10
- Visual Studio Enterprise 2015
- Microsoft IIS 10.0 Express
- MVC 5 with Entity Framework
到目前为止一切正常,我能够显示网站。
创建模型之后,使用实体框架的控制器之后我收到了此错误消息。
Until now everything worked fine and I was able to display the website. After creating a model and after that a controller using the entity framework I got this error message.
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
<首先,我首先提出了错误消息给我的建议。
So first I started with the suggestions the error message is giving me.
这两个都运行良好。
- cd进入IIS Express安装目录
- appcmd set config /section:system.webServer/directoryBrowse / enabled:true
然后我尝试运行此命令:
appcmd set config [SITE_NAME] / section:system.webServer/directoryBrowse / enabled:true
Then I tried to run this command:
appcmd set config ["SITE_NAME"] /section:system.webServer/directoryBrowse /enabled:true
其中我将 [SITE_NAME]
替换为:
- [SITE_NAME]
- [localhost]
- [MovieDb2]
- MovieDb2
- [MovieDb2]
- MovieDb2
他们都没有工作,我收到一条错误消息:
错误(消息:找不到带有标识符[SITE_NAME]的SITE对象
Where I replaced ["SITE_NAME"]
with:
- ["SITE_NAME"]
- ["localhost"]
- ["MovieDb2"]
- "MovieDb2"
- [MovieDb2]
- MovieDb2
None of them worked and I got an error message:
ERROR ( message:Cannot find SITE object with identifier ["SITE_NAME"]
我能够找到很多文档,但是所有这些都回到了 .ASPX
格式和旧版本的IIS Express。
I have been able to find a lot of documentation, but that all goes back to .ASPX
format and older versions of IIS Express.
在Visual Studio中我正确地使用clicke d在应用程序的一个index.cshtml文件上单击设置为起始页
即使在重建之后,这也不起作用。
In Visual Studio I right clicked on one of the index.cshtml files of the application and clicked "Set as start page"
This didn't work, even after a rebuild.
接下来,我发现了一些您必须在IIS管理器中进行一些更改的信息。我搜索了很多,但我无法找到IIS管理器。
即使使用此链接: https://msdn.microsoft.com/nl-nl/library/bb763170.aspx
命令 inetmgr
仅返回错误。
Next I found some information that you would have to make some changes in IIS manager. I have searched a lot, but I am not able to find IIS manager.
Even using this link: https://msdn.microsoft.com/nl-nl/library/bb763170.aspx
The command inetmgr
only returns an error.
到Web.config我添加了这段代码:
To Web.config I added this code:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
这也没有解决问题。
之后我按照本页中的步骤操作: HTTP错误403.14 - 禁止Web服务器配置为不列出此目录的内容
After that I followed the steps from this page: HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory
但是那里我还必须进入IIS管理器,我无法找到它。
But there I also have to get into the IIS manager, which I am not able to find.
我真的希望有人能为此提供解决方案。
先谢谢。
I really hope someone has a solution for this.
Thanks in advance.
推荐答案
你的根目录是空的吗?(index.html,index.aspx vb。)我觉得你的项目是web.config默认文档属性未设置。
your root directory is empty?(index.html,index.aspx vb.) and I think Your project web.config default document property is not set.
目录浏览Web.config属性
Directory Browse Web.config properties
<configuration>
<location path="special_directory_name_here">
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</location>
</configuration>
请配置您的项目默认路由设置,因为您的默认路由设置不是重定向控制器。
更改默认路线设置
http ://blogs.msdn.com/b/prakasht/archive/2013/08/08/change-the-default-route-in-asp-net-mvc.aspx
默认凭证属性web.config
Default Document Property web.config
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.php" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
这篇关于ASP.NET MVC5未针对请求的URL配置Web服务器,并且未在服务器上启用目录浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!