ASP.NET MVC Framework 4.5 CSS捆绑软件在主机上不起作用 [英] ASP.NET MVC framework 4.5 CSS bundle does not work on the hosting

查看:118
本文介绍了ASP.NET MVC Framework 4.5 CSS捆绑软件在主机上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用MVC4编写的应用程序港上运行一个应用程序.

I am runing an App on app harbor written in MVC4.

一堆css文件不起作用.在调试模式下的本地计算机中,我看到了应用程序的代码,并且看到了文件.该应用程序可以正常运行.

A bundle of css files doesn't work. In my local computer in debug mode I see the code of the App and I see the files. The App works as expected.

<link href="/Content/css/home/basic-jquery-slider.css" rel="stylesheet"/>
<link href="/Content/css/home/Home.css" rel="stylesheet"/>

当我将应用程序上载到Appharbor时,我在代码中看到了捆绑包,但该应用程序无法正常工作.

When I upload the app to Appharbor I see the bundle in the code but the App doesn't work.

<link href="/Content/css/home?v=zhVOIpUNuvCOZhJyBcQWpMlozayor4te6k-pM29wHqI1" rel="stylesheet"/>

当我在href中浏览该链接时,我得到 403-禁止访问:被拒绝.

When I browse that link in the href I get 403 - Forbidden: Access is denied.

如何解决此问题?

推荐答案

我的猜测是,路径Content/css存在于应用程序的磁盘上.在这种情况下,IIS将处理请求,而不是MVC.

My guess is that the path Content/css exists on disk in your app. In this case IIS would be handling the request, not MVC.

确保捆绑包的虚拟路径(StyleBundle构造函数的参数)与文件系统中的文件夹不匹配.

Make sure that the virtual path for the bundle (the parameter of the StyleBundle constructor) doesn't match a folder in the file system.

从评论中:

创建捆绑包时要遵循的一个很好的约定是 "bundle"作为捆绑名称中的前缀.这样可以避免可能的情况 路由冲突."

"A good convention to follow when creating bundles is to include "bundle" as a prefix in the bundle name. This will prevent a possible routing conflict."

这篇关于ASP.NET MVC Framework 4.5 CSS捆绑软件在主机上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆