我有此(简化的)ASP.NET Core Web API控制器。 GET和POST操作都可以在我自己的机器上很好地工作。但是,仅部署到Azure的GET操作才能正常工作。 POST操作会导致404错误。任何想法?ASP.NET Core Web API HTTP POST在Azure中返回404
namespace Foo
{
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
[RequireHttps]
[Produces("application/json")]
[Area("Foo")]
[Route("[area]/Api/[controller]")]
public class BarController : Controller
{
[HttpGet]
public IEnumerable<string> Get()
{
return new[] {"Hello", "World!"};
}
[HttpPost]
public void Post([FromBody] InputModel model)
{
}
public class InputModel
{
public int Foo { get; set; }
}
}
}
这是一个针对完整.NET框架的ASP.NET Core MVC应用程序。它被部署为Azure Web App。我已使用Postman在本地计算机和Azure上测试了这两个操作。
检查你的网络配置,看看是否允许POST请求 – Nkosi
如果我将内容类型改为除application/json(它给出了404)之外的任何内容,我发现我得到415“Unsupported Media Type”。但是这仍然不能解决我的问题。 –
您是否在发布ModelBinder可以绑定到InputModel类的东西? –