asp.net-mvc HTTP 错误 403.14 - Forbidden Web 服务器配置为不列出内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17631211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents
提问by F11
I have downloaded the MVC Music Store ASP.NET application at location C:\Users\DEVESH\Desktop\Projects\MvcMusicStore-v3.0\MvcMusicStore-Completed\MvcMusicStore and added the website on IIS at the same location. I have also given permission to IIS_IUSRS, but when I run localhost I am getting the error:
我已经在 C:\Users\DEVESH\Desktop\Projects\MvcMusicStore-v3.0\MvcMusicStore-Completed\MvcMusicStore 下载了 MVC Music Store ASP.NET 应用程序,并在同一位置在 IIS 上添加了网站。我还授予了 IIS_IUSRS 的权限,但是当我运行 localhost 时出现错误:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
HTTP 错误 403.14 - Forbidden Web 服务器配置为不列出此目录的内容。
I have googled it, but have not found a fix. What I am doing wrong?
我用谷歌搜索过,但没有找到解决办法。我做错了什么?
回答by Daniel Persson
I came across this error because I had the wrong .NET version (v2.0 instead of v4.0) configured on the web site application pool. I fixed it this way on Windows Server 2008 R2 and IIS 7. I'm pretty sure the instructions apply to Windows Server 2012 and IIS 8 as well:
我遇到此错误是因为我在网站应用程序池上配置了错误的 .NET 版本(v2.0 而不是 v4.0)。我在 Windows Server 2008 R2 和 IIS 7 上以这种方式修复了它。我很确定这些说明也适用于 Windows Server 2012 和 IIS 8:
- Press keys Windows+Rto open the Run dialog, type inetmgrand then click OK. This opens the IIS Manager.
- In the left treeview, locate the Sitesnode and find the Default Web Sitenode under it (or the name of the site where the error message appears).
- Right-click the node and select Manage web site -> Advanced settings.... Note the name of the value Application pool. Close this dialog.
- In the treeview to the left, locate and select the node Application pools.
- In the list to the right, locate the Application pool with the same name as the one you noted in the web site settings. Right-click it and select Advanced settings...
- Make sure that the .NET Framework versionvalue is v4.0. Click OK.
- 按Windows+R键打开“运行”对话框,键入inetmgr,然后单击“确定”。这将打开 IIS 管理器。
- 在左侧的树视图中,找到站点节点并在其下找到默认网站节点(或出现错误消息的站点的名称)。
- 右键单击该节点并选择Manage web site -> Advanced settings...。请注意值Application pool的名称。关闭此对话框。
- 在左侧的树视图中,找到并选择节点Application pools。
- 在右侧的列表中,找到与您在网站设置中记下的名称相同的应用程序池。右键单击它并选择高级设置...
- 确保.NET Framework 版本值为v4.0。单击“确定”。
This doesn't apply if you're running an older site that actually should have .NET v2.0, of course :)
当然,如果您运行的是实际应该具有 .NET v2.0 的旧站点,则这不适用:)
回答by Ruslan_K
In my case ASP.NET not registered on server. try to execute this in command prompt:
就我而言,ASP.NET 未在服务器上注册。尝试在命令提示符下执行此操作:
Windows 32bit
视窗 32 位
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir
Windows 64bit
视窗 64 位
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
回答by ATHER
Just in case if anyone reached here looking for solution, here is how i resolved it. By mistake I deleted all files from my server ( bin directory ) but when i recopied all files i missed App_global.asax.dll and App_global.asax.compiled files. Because these files were missing IIS was giving me this error
以防万一如果有人来这里寻找解决方案,这就是我解决它的方法。我错误地从我的服务器( bin 目录)中删除了所有文件,但是当我重新复制所有文件时,我错过了 App_global.asax.dll 和 App_global.asax.compiled 文件。因为这些文件丢失了 IIS 给了我这个错误
403 - Forbidden: Access is denied.
As soon as i added these files, it started working perfectly fine.
一旦我添加了这些文件,它就开始工作得很好。
回答by Luke Zaparaniuk
I resolved this issue by correcting an error with my Global.asax file arrangement. I had copied across the files from another project and failed to embed the Global.asax.cs within the Global.asax file (both files previously existed at the same level).
我通过更正 Global.asax 文件排列的错误解决了这个问题。我从另一个项目中复制了文件,但未能将 Global.asax.cs 嵌入 Global.asax 文件(这两个文件以前都存在于同一级别)。
回答by David Bennington
I have encountered similar myself before for 2 reasons; 1. MVC is not installed. 2. The url routing module is not registered (this varies by machine in my workplace for a reason I cannot fully explain - it is not always registered at a system level ), try registering it in the application web.config:
我之前遇到过类似的原因有两个;1.没有安装MVC。2. url 路由模块未注册(这在我的工作场所因机器而异,原因我无法完全解释 - 它并不总是在系统级别注册),尝试在应用程序 web.config 中注册它:
<system.web>
...
<httpModules>
...
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
Edit: I forgot to add the location for iis 7+:
编辑:我忘了为 iis 7+ 添加位置:
<system.webServer>
<modules>
...
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
</system.webServer>
回答by Priyank Agarwal
I was using ASP.NET 4.5 MVC application on IIS 7. My fix was to set runallmanagedmodule to true.
我在 IIS 7 上使用 ASP.NET 4.5 MVC 应用程序。我的解决方法是将 runallmanagedmodule 设置为 true。
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
or If you have other modules, you may want to add them inside the module tag.
或者如果您有其他模块,您可能希望将它们添加到模块标签中。
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLogWeb" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
...
</modules>
</system.webServer>
回答by Jon Schneider
This error can happen when, in IIS Manager, the ASP.NET MVC site is pointed to the wrong directory.
当在 IIS 管理器中将 ASP.NET MVC 站点指向错误的目录时,就会发生此错误。
In my case, I inadvertently had the site pointed to the solution directory instead of the child project directory. That is, I had the site's Physical pathset to
就我而言,我无意中让站点指向解决方案目录而不是子项目目录。也就是说,我将网站Physical path设置为
C:\dev\MySolution
C:\dev\MySolution
instead of
代替
C:\dev\MySolution\MyProject.
C:\dev\MySolution\MyProject.
Specific steps to fix this:
解决此问题的具体步骤:
- Open IIS Manager (Start > Run > inetmgr);
- In IIS Manager, in the left pane, expand Sites;
- Under Sites, left-click the ASP.NET MVC website;
- In the right pane, click Basic Settings...;
- In the Edit Site dialog, change the
Physical pathto the project directory. - Click OK.
- 打开 IIS 管理器(开始 > 运行 > inetmgr);
- 在 IIS 管理器的左窗格中,展开站点;
- 在站点下,左键单击 ASP.NET MVC 网站;
- 在右侧窗格中,单击基本设置...;
- 在“编辑站点”对话框中,将 更改
Physical path为项目目录。 - 单击确定。
回答by Hüseyin Ya?l?
This error occurs when the application cannot startup.
So the cause can be anything that prevents your application to start.
当应用程序无法启动时会发生此错误。
因此,原因可能是任何阻止您的应用程序启动的因素。
- Wrong connection string
- Wrong IIS directory permissions
- An exception thrown in your Application_Start() function
- IOC Container initialization error
- IIS ASP.NET registration errors
- Missing DLL in your bin folder
- etc...
- 错误的连接字符串
- 错误的 IIS 目录权限
- Application_Start() 函数中抛出的异常
- IOC 容器初始化错误
- IIS ASP.NET 注册错误
- bin 文件夹中缺少 DLL
- 等等...
回答by John
I've just had the same problem, but my fix was that the Routing was not configured in the Global.asax.cs file. I'm using Bootstrapper and Castle Windsor, so to resolve this problem I added the following code to Global.asax.cs:
我刚刚遇到了同样的问题,但我的解决方法是在 Global.asax.cs 文件中没有配置路由。我正在使用 Bootstrapper 和 Castle Windsor,所以为了解决这个问题,我在 Global.asax.cs 中添加了以下代码:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
Bootstrapper.IncludingOnly.Assembly(Assembly.GetAssembly(typeof(WindsorRegistration)))
.With
.Windsor()
.With
.StartupTasks()
.Start();
}
}
Obviously if you are using the basic MVC then you will need to reference the RouteConfig file in the AppStart folder instead:
显然,如果您使用的是基本 MVC,那么您将需要引用 AppStart 文件夹中的 RouteConfig 文件:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
回答by rns
In my case, i had multiple projects but i had not defined the starting Project. So this error was generating. After defining the startUp project solved the issue.
就我而言,我有多个项目,但我没有定义起始项目。所以这个错误正在产生。定义启动项目后解决了这个问题。


