简体   繁体   中英

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?

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; in the 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

@Styles.Render("~/assets/styles")
@Scripts.Render("~/assets/scripts") 

It's likely due to the assets folder already existing. Have you tried just using ~/styles and ~/scripts ?

The assumption you've made is that because the assets/styles folder doesn't exist a virtual path will be created. 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. 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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM