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

编程入门 行业动态 更新时间:2024-10-17 17:25:20
本文介绍了.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请求与支持的文件类型不匹配

本文发布于:2023-11-02 17:06:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552942.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件类型   不匹配   NET   Core   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!