我用。net 4.5使用razor引擎。当在本地用visual studio运行时,它工作良好。
当我在windows server 2008 R2上部署到IIS时(所有windows更新都已完成),我的包似乎不工作,并且CCS没有加载。我试着在服务器上查看网站,查看的源代码转到css的捆绑链接,它加载了一些css,然后出现IIS错误:
HTTP错误403.14-禁止Web服务器配置为不列出此目录的内容。
我尝试过的:
1)确保。安装了. net 4.5。< br> 2)增加了<代码>
你会在这里找到你的答案:ASP.NETMVC框架4.5 CSS包在主机上不起作用
简短的回答是确保您的捆绑包名称不会与站点中的路径名称冲突。
这为我解决了它(解决方案来自 MVC4 HTTP 错误 403.14 - 禁止)
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
确保在web.config中启用了对“虚拟”捆绑包路径的匿名访问。
例如,如果你的样式包像“~/content/blahblah”,你的javascript包像“~/scripts/blahblah”,你必须在你的web.config中打开对位置“content”和“scripts”的匿名访问:
<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>
这样,任何用户对虚拟路径“~/角”或“~/脚本”的任何请求都将被授予,并提供CSS和JS请求。