65.9K
CodeProject is changing. Read more.
Home

Turning local paths from an HTML code in external accessible paths

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Feb 19, 2011

CPOL
viewsIcon

8389

Turning local paths from an HTML code in external accessible paths

Let's say you have a project where you coded some stuff to get all links (href) from a webpage (html) but the links are all local paths like /pages/download.php The code provided below is an simple example on how to turn these into a full path with only needing 3 lines of code and a url. The code below is pretty easy and short but works great.
var Url = new Uri("http://website.com/");
var newurl = new Uri(Url, "/path/download.php");
string path = newurl.ToString();
Edit Another solution to this problem submitted by: DaveAuld Thank you :)
String fullurl = new Uri(new Uri("http://website.com"), "/path/download.php").ToString();