【发布时间】:2013-12-16 10:54:23
【问题描述】:
我在使用HttpClient 和BaseAddress 属性调用webHttpBinding WCF 端点时遇到问题。
HttpClient
我创建了一个HttpClient 实例,将BaseAddress 属性指定为本地主机端点。
GetAsync 调用
然后我调用 GetAsync 方法,传入额外的 Uri 信息。
HttpResponseMessage response = await client.GetAsync(string.Format("/Layouts/{0}", machineInformation.LocalMachineName()));
服务端点
[OperationContract]
[WebGet(UriTemplate = "/Layouts/{machineAssetName}", ResponseFormat = WebMessageFormat.Json)]
List<LayoutsDto> GetLayouts(string machineAssetName);
问题
我遇到的问题是 BaseAddress 的 /AndonService.svc 部分被截断,因此结果调用转到 https://localhost:44302/Layouts/1100-00277 而不是 https://localhost:44302/AndonService.svc/Layouts/1100-00277 导致 404 Not Found。
BaseAddress 在 GetAsync 调用中被截断是否有原因?我该如何解决这个问题?
【问题讨论】:
标签: c# .net wcf dotnet-httpclient webhttpbinding