[英]URI formats are not supported in webclient c#
如您所见,我致电我的服务:
public ReceptionView ReceptionViewByReceptionId(string receptionId)
{
ClientRequest.Headers["Content-type"] = "application/json";
ClientRequest.Encoding = System.Text.Encoding.UTF8;
string result = ClientRequest.DownloadString("http://localhost:1111" + " /ReceptionService.svc/ReceptionViewByReceptionId/" + receptionId);
var javascriptserializer = new JavaScriptSerializer();
return javascriptserializer.Deserialize<ReceptionView>(result);
}
但是我在DownloadString
收到此错误:
{"URI formats are not supported."}
我的服务正常,当我通过浏览器调用我的服务时,如下所示:
http://localhost:1111/ReceptionService.svc/ReceptionViewByReceptionId/1
我得到了预期的结果。但是在我的应用程序中,我无法
我的服务界面
[WebGet( UriTemplate = "/ReceptionViewByReceptionId/{receptionId}", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
ReceptionView ReceptionViewByReceptionId(string receptionId);
值得注意的是,我的函数之前没有任何错误,但是今天突然返回了此错误。
问题是这里的空格" /Reception
,您可以在url中看到
string result = ClientRequest.DownloadString("http://localhost:1111" + " /ReceptionService.svc/ReceptionViewByReceptionId/" + receptionId);
我删除了所有内容,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.