从Webforms到Web API 2 (Azure)的PUT方法无效

本文关键字:PUT 方法 无效 Azure Webforms Web API | 更新日期: 2023-09-27 17:54:30

我在Azure服务器上有一个Web API,我正在从ASP进行调用。. NET Webforms网站。

我似乎可以毫不费力地执行GET。现在对于PUT,它给了我这个错误:

由于无效,无法显示您正在查找的页面方法(HTTP动词)正在被使用

我也不能删除。我看到一些其他的话题,人们在他们的IIS服务器上禁用一些WebDav和东西,它工作。但在Azure上呢?

在我的PUT代码下面:

HttpResponseMessage response = client.GetAsync("api/People/" + id).Result;
if (response.IsSuccessStatusCode)
{
    var yourcustomobjects = response.Content.ReadAsAsync<People>().Result;
    Uri peopleUrl = response.Headers.Location;
    yourcustomobjects.name= "Bob"; 
    response = await client.PutAsJsonAsync(peopleUrl, yourcustomobjects);
    tbDebug.Text += await response.Content.ReadAsStringAsync();
}

从Webforms到Web API 2 (Azure)的PUT方法无效

好吧,我已经厌倦了通过启用PUT来解决这个问题。

所以我写了一个GET,在数据库中做了必要的修改。

欢呼