gpt4 book ai didi

asp.net-core - .NET Core API 请求与支持的文件类型不匹配

转载 作者:行者123 更新时间:2023-12-03 22:54:52 26 4
gpt4 key购买 nike

我只是想确保我在这里没有问题。有谁知道是什么原因造成的

2017-03-17 07:59:17.5838|1|Microsoft.AspNetCore.Hosting.Internal.WebHost|INFO|Request starting HTTP/1.1 GET http://192.168.20.57:8081/hardware/configuration/active application/json  
2017-03-17 07:59:17.5868|4|Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware|DEBUG|The request path /hardware/configuration/active does not match a supported file type

我仅通过 Kestrel 公开 Web API(没有 IISIntegration)。

请求头包含
GET /hardware/configuration/active HTTP/1.1
Accept: application/json, text/plain, */*
Content-Type: application/json

定义 [Produces("application/json")]明确在我的 Controller 中没有效果。

最佳答案

将 StaticFileOptions.ServeUnknownFileTypes 设置为 true:

        app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider("mypath"),
ServeUnknownFileTypes = true // <<<<<<
});

或者找出可以扩展未知类型的位置(在后一种情况下请告诉我)。

关于asp.net-core - .NET Core API 请求与支持的文件类型不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42851502/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com