ASP.NET MVC 框架 4.5 CSS 包在托管上不起作用 [英] ASP.NET MVC framework 4.5 CSS bundle does not work on the hosting

查看:29
本文介绍了ASP.NET MVC 框架 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 - Forbidden: Access is denied.

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.

来自评论:

"创建包时要遵循的一个很好的约定是包含捆绑"作为捆绑名称中的前缀.这将防止可能的路由冲突."

"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 框架 4.5 CSS 包在托管上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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