HTTP 错误 403.14 - 禁止 - MVC4 .net 4.5 包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13482637/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:43:31  来源:igfitidea点击:

HTTP Error 403.14 - Forbidden - MVC4 .net 4.5 bundles

.netasp.net-mvciisrazor.net-4.5

提问by Kyle

I made a MVC4 application with .net 4.5 using razor engine. It works fine when run locally with visual studio.

我使用 razor 引擎用 .net 4.5 制作了一个 MVC4 应用程序。使用visual studio在本地运行时效果很好。

When I deploy to IIS on windows server 2008 R2(all windows updates done), it appears my bundles do not work and the CCS is not loading. I tried viewing the site on the server, viewed source went to the bundle link for the css, and it loads some css and then there is an IIS error of:

当我在 Windows Server 2008 R2 上部署到 IIS(所有 Windows 更新完成)时,我的包似乎不起作用并且 CCS 没有加载。我尝试在服务器上查看该站点,查看的源代码转到了 css 的捆绑链接,它加载了一些 css,然后出现了以下 IIS 错误:

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

HTTP 错误 403.14 - Forbidden Web 服务器配置为不列出此目录的内容。

What I have tried:

我尝试过的:

1) Ensured .net 4.5 is installed.
2) Added <modules runAllManagedModulesForAllRequests="true"/>to my web.config
3) Ran %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -irin cmd
4) Checked that my app pool was set to Integrated Mode
5) Checked that it's set to use .net 4

1) 确保安装了 .net 4.5。
2) 添加<modules runAllManagedModulesForAllRequests="true"/>到我的 web.config
3)%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir在 cmd 中运行
4) 检查我的应用程序池是否设置为集成模式
5) 检查它是否设置为使用 .net 4

回答by Rich Turner

You'll find your answer here: ASP.NET MVC framework 4.5 CSS bundles does not work on the hosting

您将在此处找到答案:ASP.NET MVC 框架 4.5 CSS 包在托管上不起作用

The short answer is to make sure that your bundle names don't conflict with the names of paths in your sites.

简短的回答是确保您的包名称与站点中的路径名称不冲突。

回答by silverfox1948

This solved it for me (solution is from MVC4 HTTP Error 403.14 - Forbidden)

这为我解决了(解决方案来自MVC4 HTTP Error 403.14 - Forbidden

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true"/> 
 </system.webServer>

回答by Isaac Llopis

Make sure that in your web.config you have enabled anonymous access to your "virtual" bundles paths.

确保在您的 web.config 中您启用了对“虚拟”包路径的匿名访问。

For instance, if your style bundles are like "~/content/blahblah" and your javascript bundles are like "~/scripts/blahblah" you must open anonymoys access to locations "content" and "scripts" like this in your web.config:

例如,如果您的样式包类似于“~/content/blahblah”,而您的 javascript 包类似于“~/scripts/blahblah”,则您必须在 web.config 中打开对“内容”和“脚本”位置的匿名访问权限:

<configuration>
 ...
 <location path="content">
  <system.web>
   <authorization>
    <allow users="?" />
   </authorization>
  </system.web>
 </location>

 <location path="scripts">
  <system.web>
   <authorization>
    <allow users="?" />
   </authorization>
  </system.web>
 </location>
 ...
</configuration>

This way, any request to the virtual path "~/content" or "~/scripts" by any user will be granted, and the CSS and JS requests will be served.

这样,任何用户对虚拟路径“~/content”或“~/scripts”的任何请求都将被授予,并且将提供 CSS 和 JS 请求。

回答by Simon

Another potential problem that causes the 403.14 is the global.asax and/or the web.config not being copied across in your publishing settings or deployment.

导致 403.14 的另一个潜在问题是 global.asax 和/或 web.config 未在您的发布设置或部署中复制。