Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get ASP.NET bundle URL for use with CDN?

I'm using the ASP.NET bundling feature and want to know how I can get the URL returned by the Render helpers such as Scripts.Render("~/bundles/scripts").

Currently the optimized output is has a relative URL. I want to use a CDN that does origin-caching, so the final URL needs to be something like http://static.mydomain.com/bundles/scripts?v=XXXXXX

My plan is to simply write my own helper method, but I can't figure out how to get the version number relative URL for a given bundle.

like image 426
Brian Vallelunga Avatar asked Nov 17 '25 00:11

Brian Vallelunga


1 Answers

The solution was rather simple. There is a static method Scripts.Url and Styles.Url that give me exactly what I want. I was able to incorporate this into my own helper to concatenate the CDN's base URL.

like image 185
Brian Vallelunga Avatar answered Nov 19 '25 13:11

Brian Vallelunga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!