Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 475
Keltex Avatar asked Mar 27 '13 22:03

Keltex


1 Answers

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.

like image 66
Hao Kung Avatar answered Nov 03 '22 08:11

Hao Kung