Implement CDN with ASP.NET website

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.

Regardless of your CDN choice, once you have your assets in place you should mirror the same folder structure on your CDN. This will allow you to switch between locally deployed assets and those on the CDN.

On code level you can use something like:

Here method “GetCDNPath()” picks up the CDN url and pre-appends it to the relative path of static resource.

In web.config file, you need to add CDNPath key-value under appSettings element: