我正在使用ServiceStack(ServiceStack客户端是4.0.12.0)。
我有一些代码如下:
private async Task TestSave()
{
JsonServiceClient client = new JsonServiceClient("http://localhost:60982");
try
{
this.Items = client.Post(new ItemDescUpdateRequest() { Items = this.Items });
}
catch (WebServiceException ex)
{
HandleWebException(ex);
}
}
如果我使用Post并且服务器抛出异常。服务器异常正确返回。我可以使用ex.ErrorMessage来查看消息。但是,如果我改为:
this.Items = await client.PostAsync(new ItemDescUpdateRequest() { Items = this.Items
无法正确处理异常。
ResponseBody和ResponseDTO一样有数据。但是ResponseStatus为null。 ErrorCode和ErrorMessage得到System.IndexOutOfRangeException错误,我假设因为ResponseStatus为null。
为什么PostAsync不按预期工作?