I use the following code to remove http:// and www. or dev. from a URL:
Uri uri = new Uri(this.Referrer);
if (uri != null )
return uri.GetLeftPart(UriPartial.Authority).Replace("http://dev.", "").Replace("http://www.", "").Replace("http://", "");
else
return null;
I don't like that I'm relying on the .Replace() function. I had a bug for quite a while until I realized that the this.Referrer didn't have the subdomain.
Is there a more elegant way to do this?