Proper way to grab URL without http or subdomain
I am successfully able to retrieve just the URL without the http:// or the
subdomain
Here is how I'm doing it.
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?
No comments:
Post a Comment