Brian Vallelunga
Brian Vallelunga

Reputation: 10191

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.

Upvotes: 3

Views: 1187

Answers (1)

Brian Vallelunga
Brian Vallelunga

Reputation: 10191

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.

Upvotes: 4

Related Questions