Relative URL's to absolute URL's function ?

  • Thread starter Thread starter wl
  • Start date Start date
W

wl

Hi,

I would like to create a new URL based on the URLReferer. Well it's
difficult to explain (which is probably I can't find anything on Google):

eg 1
URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value =
"asecondfile.aspx"
--> http://www.mysite.com/somedir/asecondfile.aspx

eg2:
URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value =
"../asecondfile.aspx"
--> http://www.mysite.com/asecondfile.aspx

eg2:
URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value =
"http://www.anothersite.com/asecondfile.aspx"
--> http://www.anothersite.com/asecondfile.aspx

So this basically would need to translated relative URL's to absolute URL's.

Is there any method in the framework that can do this for me, without having
to write my own code ?

Thanks,

Wim
 
While describing my problem I found a good description and tried this in
Google, and I found it.

[C#]
Uri baseUri = new Uri("http://www.contoso.com/");
Uri myUri = new Uri(baseUri, "catalog/shownew.htm?date=today");

Console.WriteLine(myUri.AbsolutePath);

Thanks,

Wim
 
Back
Top