asp.net mvc 5 - StyleBundle CdnFallbackExpression questions?

后端 未结 1 413
北海茫月
北海茫月 2021-01-02 22:15

I\'ve added bootstrap CSS files via a StyleBundle to my asp.net mvc 5 project.

(It uses as Cdn: https://www.asp.net/ajax/cdn#Bootstrap_Releases_on_the_CDN_14 )

相关标签:
1条回答
  • 2021-01-02 22:41

    1) This is a bug in the Microsoft ASP.NET Optimization Framework, documented here.

    2) The solution is to modify the CdnFallbackExpression to be a javascript function that both checks for the stylesheet and loads the fallback, thus ignoring the bad script from the Optimization Framework.

    Here is solution which provides a StyleBundle extension method to solve the problem: Style Bundle Fallback.

    3) There should be unminified version like bootstrap.css (not bootstrap.min.css). When you build your web application for release it uses .min version. More here: Bundler not including .min files.

    4) No, you can't use multiple CSS files with CDN (each of them must have its own bundle). Here is an article that explains when to use a CDN (or not) and why: Know When To CDN.

    0 讨论(0)
提交回复
热议问题