views:

291

answers:

2
+3  A: 

Add a trailing "/" to apiUri, and remove the leading "/" from method.Path:

        Uri apiUri = new Uri("http://www.r-s.co.uk/eproxy.php/");
        string path = "char/SkillIntraining.xml.aspx";
        Uri uri = new Uri(apiUri, path);
        Console.WriteLine(uri.ToString());
Jim Mischel
Spot on, thanks.
Richard Slater
+1  A: 

Don't use the Uri object, use a UriBuilder - it copes way better with missing slashes

So

Uri apiUri = new Uri("http://www.r-s.co.uk/eproxy.php");
string methodPath = "/char/SkillIntraining.xml.aspx";

System.UriBuilder uriBuilder = new System.UriBuilder(apiUri);
uriBuilder.Path += methodPath;

Console.WriteLine(uriBuilder.Uri.ToString());

works as expected and produces http://www.r-s.co.uk/eproxy.php/char/SkillIntraining.xml.aspx

blowdart
You are correct System.UriBuilder is a more robust way of building URIs, thanks.
Richard Slater
JT