Uri Class?

B

Brian

I have a URL and am using an HttpWebRequest to connect to the web and
download the page. When I have the page contents I use RegEx and search the
page for any <a href=> links. The links usually contain something like
"./blah/mypage.html". What I need to do is take the original URL and
combine it with what I found in the href. So if my original URL is
http://www.mysite.com?var=something&blah=2 and then I combine it with what
is shown above - the result I want to see is
http://www.mysite.com/blah/mypage.html

Is there a class that can do this?

TIA!
Brian
 
P

Patrick Steele

I have a URL and am using an HttpWebRequest to connect to the web and
download the page. When I have the page contents I use RegEx and search the
page for any <a href=> links. The links usually contain something like
"./blah/mypage.html". What I need to do is take the original URL and
combine it with what I found in the href. So if my original URL is
http://www.mysite.com?var=something&blah=2 and then I combine it with what
is shown above - the result I want to see is
http://www.mysite.com/blah/mypage.html

Is there a class that can do this?

The Uri class can do this:

Uri baseUri = new Uri("http://www.mysite.com?var=something&blah=2");
string page = "./blah/mypage.html";
Uri finalUri = new Uri(baseUri, page);
 

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

Top