views:

46

answers:

2

I'm working on as asp.net application. The application is reasonably large and involves lot of pages with many reference images and scripts. I have hosted such content on a cookie-free sub-domain.

My problem is - I have to manually update the path for all images and scripts upon deployment, by making them absolute-references to cookie-free domain content from relative-references of actual domain. How do I automate this ? Has anybody done this ?

StackOverflow also uses cookie-free domain for various images on the site. Here's example upvote image which loaded from http://sstatic.net/so/img/vote-arrow-up.png

alt text

A: 

I solved a similar problem with custom controls (Images, etc.). Some I derived from existing controls (Image) some I created new.

Within these Controls you could decide if you are in your dev environment or in production and render/change your links.

EDIT: Add some example code. Note! This code is for demonstration purpose only! It's not perfekt!

public class ExternalImage : System.Web.UI.WebControls.Image
{
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (System.Configuration.ConfigurationManager.AppSettings["IsDev"] != "true")
        {
            this.ImageUrl = System.Configuration.ConfigurationManager.AppSettings["CookieFreeDomain"] + this.ImageUrl;
        }
    }
}
Arthur
I see some hope here. You are identifying path based on build configuration. Can you please put more detailed example or some code ?
this. __curious_geek
Sorry, it's a closed source project. We identified the Paths based on a configuration in the web.config file. I'll edit my answer with a little example
Arthur
A: 

You can use tag transforms or control adapters.

In case it helps, I cover both approaches in my book, along with code examples: Ultra-Fast ASP.NET

RickNZ