我的Entity Framework Core API在本地运行良好,但由于生产中出现405错误而失败

问题描述 投票:1回答:1

我有一个使用实体框架的.NetCore 3.1 API项目。

当我从Visual Studio本地运行它时,它运行良好。

但是,发布到生产IIS 8.5服务器后,当我尝试在生产服务器上使用PUT的API时出现以下错误。

xhr.js:178 PUThttps://nationalparks.xyz.gov/api/plants/91405(方法不允许)

我的控制器开始这样:

    [HttpPut("{id}")]
    public async Task<IActionResult> PutPlant(long id, [FromBody] Plant plant)
    {
      ...
    }

并且客户端看起来像这样:

    await axios({
        method: "PUT",
        url: "api/plants/" + plant.id,
        data: JSON.stringify(plant),
        headers: { 'Content-Type': 'application/json; charset=utf-8' }
    });

老实说,我很困惑...我不确定为什么要这么做。

[我已经看到一些帖子说要修改web.config,但是我的应用使用的是appsettings.json,而不是web.config。

有什么想法吗?

谢谢!

asp.net-core iis entity-framework-core asp.net-core-3.0 iis-8.5
1个回答
0
投票

dotnet核心应用程序在IIS下运行时确实使用web.config。您会注意到publish命令生成一个web.config文件,该文件告诉IIS为您的应用程序运行哪个DLL。

我想我前一段时间也有同样的问题。我通过在web.config上添加行来删除WebDAV模块来解决此问题。请参阅此答案以获取更多详细信息:

https://stackoverflow.com/a/12443578/65432

© www.soinside.com 2019 - 2024. All rights reserved.