【发布时间】:2017-08-29 23:42:14
【问题描述】:
我正在调整最近在 .NET Standard 中启动的项目以使用 Azure Functions。我有一个 HTTP 触发器,我直接从表单发布到该触发器。只有两个字段:数字输入和文件上传。
在不引用任何其他库的情况下使用该函数时,我无法在 HttpRequestMessage 上使用 ReadAsFormDataAsync。我收到一个:
System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is
available to read an object of type 'FormDataCollection' from content with
media type 'multipart/form-data'.
我可以使用 ReadAsMultipartAsync 并设法获取帖子值。
当我引用 .NET Standard 库时,我什至无法输入该函数,因为它被完全拒绝:
System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is
available to read an object of type 'HttpRequestMessage' from content with
media type 'multipart/form-data'
我尝试创建一个全新的骨架 .NET Standard 库并引用它和相同的东西。
作为附加参考,我找到了this post,但我似乎没有遇到同样的问题。
本来打算提出问题,但决定先在这里尝试。有什么想法吗?
编辑:当 enctype 为 application/x-www-form-urlencoded 时也会发生这种情况。
【问题讨论】:
标签: c# azure azure-functions