There’s no reason not to use a CDN service like such as Akamai, Amazon CloudFront or Windows Azure, especially when most of end-user response time is spent downloading static resources like images, css and scripts.
On code level you can use something like:
<img src='<%= GetCDNPath()assets/images/sample.png' />
Here method “GetCDNPath()” picks up the CDN url and pre-appends it to the relative path of static resource.
public string GetCDNPath() { get { return ConfigurationManager.AppSettings["CDNPath"].ToString(); } }
In web.config file, you need to add CDNPath key-value under appSettings element:
<appSettings> <add key="CDNPath" value="http://my.cdn.com/user/"/> </appSettings>
Enjoy!!
(Visited 265 times, 1 visits today)