How to add CDN to bundle.config in asp.net webforms bundling

Keltex picture Keltex · Mar 27, 2013 · Viewed 7.1k times · Source

I am using asp.net bundling / minification and putting everything in bundle.config like this:

<styleBundle path="~/css/css">
  <include path="~/css/bootstrap.css" />
  <include path="~/css/flexslider.css" />
  <include path="~/css/font-awesome.css" />
  <include path="~/css/Site.css" />
  <include path="~/css/orange.css" />
</styleBundle>

But I would like to use bootstrap.css from a CDN:

//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css

So how can we do this in the bundle.config?

Answer

Hao Kung picture Hao Kung · Mar 28, 2013

Currently you cannot mix and match and pull some of the files in your bundle from an external source like a cdn. You could upload the entire bundle to a CDN and configure the helpers to render a reference to the bundle in a CDN, but you cannot include files from external sources, the files must live somewhere that your app can find.

You could work around this by implementing a VirtualPathProvider that was able to fetch files from your CDN at runtime, but you would have to build that yourself.