简体   繁体   English

POST 请求正文在 IIS 服务器上导致 404

[英]POST request body causes 404 on IIS server

I have a React frontend and aspnet core backend.我有一个 React 前端和 aspnet 核心后端。 It seems like the post request body sometimes causes a 404 from IIS.似乎发布请求正文有时会导致来自 IIS 的 404。

It works fine locally when I run the backend from VS.The symptom appears only in customers environment where the app runs on a IIS server.当我从 VS 运行后端时,它在本地运行良好。该症状仅出现在应用程序在 IIS 服务器上运行的客户环境中。

The issue seems to be that the request body contains an array.问题似乎是请求正文包含一个数组。 All is fine if the array is empty.如果数组为空,一切都很好。

Request body - no problem:
[
  {
    "foo": "bar",
    "zot": []
  }
]

Request body - gives 404
[
  {
    "foo": "bar",
    "baz": [
      "zot": 1
    ]
  }
]

There are reasons why there is no logging yet, which would help to find out if it is a real 404. For the same reason I don't have access or any information of the IIS-setup yet.还没有日志记录是有原因的,这将有助于确定它是否是真正的 404。出于同样的原因,我还没有访问权限或 IIS 设置的任何信息。

So my questions are: Is it possible that IIS can give 404 instead of 400 or 500?所以我的问题是:IIS 是否有可能给出 404 而不是 400 或 500? Can the POST request body cause a 404 error? POST 请求正文会导致 404 错误吗?

This is now solved.现在已经解决了。 The real cause for the error was that my db schema differed from the one in test environment.错误的真正原因是我的数据库架构与测试环境中的架构不同。 So the real error was a "Microsoft.Data.SqlClient.SqlError".所以真正的错误是“Microsoft.Data.SqlClient.SqlError”。 For some reason IIS responsed with a 404 instead of a 500.出于某种原因,IIS 响应为 404 而不是 500。

As Lex Li pointed out, there are also sub codes for 404 errors.正如 Lex Li 所指出的,404 错误也有子代码。 In this case it was 404.0.在这种情况下,它是 404.0。 It would be great to know why IIS is behaving like this and if it is configurable somehow.很高兴知道 IIS 为什么会出现这样的行为,以及它是否可以以某种方式进行配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM