I’m scraping a website for URL’s and the anchor tags all have their href value just set to the querystring eg..
<a href="?AppId=12345&CatId=13">Details</a>
The URL of the current page is something like this..
http://www.theurl.com/ThePage.aspx?PageNo=2
Therefore the url I’m looking for will be
http://www.theurl.com/ThePage.aspx?AppId=12345&CatId=13
To get this I am using the the method Uri.TryCreate, so I’m passing in the following parameters (the first two parameters are of type Uri and not string)..
Uri.TryCreate("http://www.theurl.com/ThePage.aspx?PageNo=2", "?AppId=12345&CatId=13", out uri);
However the out parameter ‘uri’ is being set to..
http://www.theurl.com/?AppId=12345&CatId=13
As you can see it removes the .aspx path. Can you recommend a better way to do this or explain why it doesn’t work as I thought it should?
Try this:
According to the docs, the first one is the base URI, the second is the relative URI.