我在 WEBUI 控制器中有一个 GetCustomerDetails 方法(下)
public bool GetCustomerDetails(string customer)
{
Uri CustUri = null;
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://online/");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = client.PostAsJsonAsync("api/customers/", customer).Result;
if (response.IsSuccessStatusCode)
{
CustUri = response.Headers.Location;
}
return false;
}
the above method has to hit the below method(API controller).
public string PostCustomer(string customerJsonString)
{
CustomerDetailDto customer = JsonConvert.DeserializeObject<CustomerDetailDto>(customerJsonString);
bool res = _customerService.SaveOrUpdateCustomer(customer);
if (res)
{
....
}
return something;
}
但作为回应(上面的WEBUI)我收到错误消息
{StatusCode:405,ReasonPhrase:'方法不允许',版本:1.1,内容:System.Net.Http.StreamContent,标头:{ Pragma:无缓存连接:关闭缓存控制:无缓存日期:星期三,17 2013 年 7 月 12:17:49 GMT 服务器:ASP.NET 服务器:开发服务器:Server/11.0.0.0 X-AspNet-Version:4.0.30319 Content-Length:73
Content-Type:application/json;charset=utf-8 过期:-1 }}
所以任何机构都可以帮助我解决这个问题。