本文介绍了.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 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请求与支持的文件类型不匹配
发布评论