[ACCEPTED]-Combining URIs and Paths-web-services
Accepted answer
Don't use the Uri object, use a UriBuilder - it copes 2 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 1 expected and produces http://www.r-s.co.uk/eproxy.php/char/SkillIntraining.xml.aspx
Add a trailing "/" to apiUri, and remove 1 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());
Will print:
http://www.r-s.co.uk/eproxy.php/char/SkillIntraining.xml.aspx
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.