我尝试构建以下 uri
http://localhost:8080/TestService.svc/RunTest
我这样做如下
var uriBuilder = new UriBuilder();
uriBuilder.Host = "localhost:8080/TestService.svc";
uriBuilder.Path = String.Format("/{0}", "RunTest");
string address = uriBuilder.ToString()
//In debugger the address looks like http://[http://localhost:8080/TestService.svc]/RunTest
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(address);
以上生成异常
Invalid URI: The hostname could not be parsed.
感谢您帮助解决问题