【发布时间】:2015-11-12 14:26:45
【问题描述】:
我尝试使用托管在远程服务器上的 WEB API 更新对象。我很好地恢复了对象,但是在更改时,答案给出了不允许的 404 方法。我测试了在附近同事的一台机器上托管我的服务。它运作良好。进行配置或其他需要什么? 非常感谢。
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage responsse = client.PutAsJsonAsync("api/Collaborateurs/" + coll.matricule_collaborateur, coll).Result;
if (responsse.IsSuccessStatusCode) {
}
错误:
{StatusCode: 405, ReasonPhrase: 'Method Not Allowed', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Thu, 12 Nov 2015 14:28:10 GMT
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Content-Length: 1343
Allow: GET
Allow: HEAD
Allow: OPTIONS
Allow: TRACE
Content-Type: text/html
}}
【问题讨论】:
标签: asp.net httpclient