【问题标题】:Invalid PUT method from Webforms to Web API 2 (Azure)从 Webforms 到 Web API 2 (Azure) 的无效 PUT 方法
【发布时间】:2016-07-04 16:39:40
【问题描述】:

我的 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();
}

【问题讨论】:

  • 你有 azure 的 web.config 吗?
  • 我假设您想要来自 API 的 web.config?还有这个部分?:
  • 抱歉,我想了解我是如何使它更具可读性的
  • Ian,对于您的链接,它需要编辑文件:%userprofile%\documents\iisexpress\config\applicationhost.config Azure 似乎没有让我访问它。

标签: c# asp.net azure asp.net-web-api2


【解决方案1】:

好吧,我厌倦了尝试通过启用 PUT 来解决此问题。

所以我所做的是,我编写了一个 GET 来在数据库中进行所需的更改。

干杯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多