.NET Core API 请求与支持的文件类型不匹配 [英] .NET Core API Request does not match a supported file type
本文介绍了.NET Core API 请求与支持的文件类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想确保我在这里没有问题.有没有人知道是什么原因造成的
I just want to make sure I have no issue here. Does anybody know what causes the
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).
I'm exposing the Web API by Kestrel only (no IISIntegration).
请求头包含
GET /hardware/configuration/active HTTP/1.1
Accept: application/json, text/plain, */*
Content-Type: application/json
定义[Produces("application/json")]
明确在我的控制器中无效.
Defining
[Produces("application/json")]
explicitly in my controller has no effect.
推荐答案
将 StaticFileOptions.ServeUnknownFileTypes 设置为 true:
Set StaticFileOptions.ServeUnknownFileTypes to true:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider("mypath"),
ServeUnknownFileTypes = true // <<<<<<
});
或者找出未知类型可以扩展的地方(如果是后一种情况,请告诉我).
or find out where the unknown types can be extended (please let me know in the latter case).
这篇关于.NET Core API 请求与支持的文件类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文