Converting relative URLs to absolute ones.
Tuesday, November 30th, 2010On a number of occasions I have found that I need to convert all URLs in a webpage from relative ones to absolute ones. This is usually done when you are displaying a page sourced from one domain from a different domain.
Note that this doesn’t really provide full emulation or proxying of a site, you need to take into account cookies, etc. to do that correctly.
Here is how I most recently cracked it (in C# .NET). This isn’t fool proof; however it should work with most HTML:

