Relative URL's to absolute URL's function ?

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
 
W

wl

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top