如何从 WebApi 中的控制器方法访问 JSON?例如下面我想访问作为参数传入的反序列化客户和序列化客户。
public HttpResponseMessage PostCustomer(Customer customer)
{
if (ModelState.IsValid)
{
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, customer);
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = customer.Id }));
return response;
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}