我正在修改最近在.NET Standard中啓動的項目以使用Azure函數。我有一個HTTP觸發器,我直接從窗體發佈到。只有兩個字段:數字輸入和文件上傳。沒有MediaTypeFormatter可用於從媒體類型爲'multipart/form-data'的內容讀取類型爲'HttpRequestMessage'的對象
在不引用任何其他庫的情況下使用該函數時,我無法在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庫的標準,雖然,我甚至無法進入,因爲它被完全拒絕的功能:
System.Net.Http.UnsupportedMediaTypeException: No MediaTypeFormatter is
available to read an object of type 'HttpRequestMessage' from content with
media type 'multipart/form-data'
我試圖創建一個全新的骨架.NET標準庫和引用這一點,一樣。
作爲附加參考,我發現this post,但我似乎沒有相同的問題。
打算提出問題,但決定先在這裏嘗試。有任何想法嗎?
編輯:當enctype是application/x-www-form-urlencoded時,也會發生這種情況。
我應該在原來的職位已經注意到這種情況也發生在enctype上。我將編輯添加。 – Dexterity
在我身邊,我可以得到application/x-www-form-urlencoded請求。如果可能的話,請發佈整個天藍色的函數http觸發代碼,您現在使用。 –
[使用functionName( 「TestPost」)] 公共靜態異步任務運行([HttpTrigger(AuthorizationLevel.Anonymous, 「後」)] HttpRequestMessage REQ,TraceWriter日誌) { 動態數據=等待req.Content.ReadAsAsync