[英]Bundling not working when deployed to azure asp mvc 4
I have css files and js files, locally link are rendered in the head as expected but on azure the links are not rendered at all, why? 我有css文件和js文件,本地链接按预期方式显示在头部,但是天蓝色时根本不显示链接,为什么?
I have looked through various threads and most seem to point towards there being an issue with naming the bundle name the same as the file path, both are different. 我浏览了各种线程,大多数似乎都指向将包名称命名为与文件路径相同的问题,两者都不同。 Others have said that
<compilation debug="true" targetFramework="4.5" />
should be <compilation debug="false" targetFramework="4.5" />
and others have said to try BundleTable.EnableOptimizations = true;
其他人说
<compilation debug="true" targetFramework="4.5" />
应该是<compilation debug="false" targetFramework="4.5" />
,其他人则说尝试BundleTable.EnableOptimizations = true;
in the Bundle.config. 在Bundle.config中。 Non have worked for me, can someone please point me in the right direction
非为我工作过,有人可以指出正确的方向吗
my bundles are 我的包是
bundles.Add(new StyleBundle("~/assets/styles").Include(
"~/assets/plugins/bootstrap/css/bootstrap.min.css",
"etc...",
"~/assets/css/theme.css"));
bundles.Add(new ScriptBundle("~/assets/scripts").Include(
"~/assets/js/filter.js",
"etc...",
"~/assets/js/ContactForm.js"));
my folder structure is 我的文件夹结构是
assets/css
assets/js
in my _Layout.cshtml they are called 在我的_Layout.cshtml中,它们被称为
@Styles.Render("~/assets/styles")
@Scripts.Render("~/assets/scripts")
It's likely due to the assets
folder already existing. 可能是由于
assets
文件夹已经存在。 Have you tried just using ~/styles
and ~/scripts
? 您是否尝试过仅使用
~/styles
和~/scripts
?
The assumption you've made is that because the assets/styles
folder doesn't exist a virtual path will be created. 您所做的假设是,因为
assets/styles
文件夹不存在,所以将创建虚拟路径。 The issue is more likely to do with Azure discovering the Directory assets
and treating everything within it as actual resources, skipping past the point of creating a virtual path. 问题很可能与Azure发现目录
assets
并将其中的所有内容都视为实际资源有关,从而跳过了创建虚拟路径的要点。 If I were you, I wouldn't bother with trying to make it work, at best you'll have what you wanted but really, at worst, you'll have wasted hours on a matter that makes no business sense and adds no real value to the UX... 如果我是你,我不会为使它工作而烦恼,充其量只有你想要的东西,但实际上,最糟糕的是,你会浪费时间在没有商业意义,没有实质意义的事情上UX的价值...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.