1

鉴于我的控制器中有以下 web api 方法

    public HttpResponseMessage PostGrantAccess(GrantAccessRequest grantAccessRequest)
    {
        var deviceId = grantAccessRequest.DeviceId;

        var grantAccessResponse = new GrantAccessResponse()
            {
                Status = "OK"
            };
        var response = Request.CreateResponse<GrantAccessResponse>(HttpStatusCode.OK, grantAccessResponse);
        return response;
    }

客户端调用代码:

using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("http://localhost:55208/");

    var request = new GrantAccessRequest { DeviceId = "bla" };
    var response = client.PostAsJsonAsync("api/accesspanel", request).Result;
    if (response.IsSuccessStatusCode)
    {
        var uri = response.Headers.Location;
    }
}

我如何回到GrantAccessResponse客户那里?

4

1 回答 1

4
response.Content.ReadAsAsync<GrantAccessResponse>()
于 2013-03-11T14:19:05.497 回答