![](/img/trans.png)
[英]ERrorInWebProjectm In Web Api Project asp>net
Hi I have a web project --> Asp.Net Core Mvc I have a class called tokenmodel I get this error when requesting the API: UnsupportedMediaTypeExcep ...
[英]ERrorInWebProjectm In Web Api Project asp>net
Hi I have a web project --> Asp.Net Core Mvc I have a class called tokenmodel I get this error when requesting the API: UnsupportedMediaTypeExcep ...
[英]Receive No MediaTypeFormatter is available to read when calling web api in browser
我有一個 Angular 7 應用程序,它帶有一個用 VB 編碼的 ASP.net web api 后端。 我可以毫無問題地發布、放置和獲取數據,但是當我嘗試通過路由或 ID 訪問數據時,這是我收到的錯誤: 請求包含實體主體但不包含 Content-Type 標頭。 此資源不支持推斷的媒體類型 ...
[英]Web API change JSON parser
我正在嘗試在我的Web API項目中更改JSON解析器。 我遵循了以下教程: https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-2.2 ...
[英]Not able to use JIL Serializer ExcludeNulls Option
我無法使用 JIL 的 Exclude Null 選項。 相反,我得到了一個例外: JIL.DeserializationException: '預期數字' 下面是代碼片段。 1) 模型類型 2) JSON 字符串: ...
[英]WebApi custom BufferedMediaTypeFormatter WriteToStream never get called
我在客戶端上使用WebApi2和angular。 我正在嘗試在我的網站中實現對Excel文件的導出。 我實現了自定義BufferedMediaTypeFormatter。 但不幸的是,它不起作用。 盡管CanWriteType函數被調用兩次並兩次返回true,但從未調用WriteToSt ...
[英]Unable to mock Configuration.Formatters using Moq
我正在開發一個 ASP.NET Web API 應用程序。 我正在對應用程序中的每個組件進行單元測試。 我正在使用 Moq 單元測試框架來模擬數據。 現在我試圖在我的單元測試中模擬Configuration.Formatters.JsonFormatter ,因為我在單元測試下的操作正在使用它,如 ...
[英]Azure Functions - Set MediaTypeFormatter for response message?
我正在嘗試為Azure函數的響應設置媒體類型格式化程序以返回Excel文件。 我不希望使用外部文件綁定,因為我想將輸出流式傳輸到瀏覽器以進行下載,而不是將文件寫入Blob或Google工作表等。 為此,在其他上下文(例如WebApi)中,我已經為此目的使用了EPPlus庫和WebApiCon ...
[英]ASP .NET Web API How to return error on unsupported media type
我的 Web API 控制器在其方法之一中處理某些第三方類 它使用自定義媒體類型格式化程序進行解析,並擁有自己的媒體類型“application/json+customType”。 問題是當參數內容類型指定不正確時(例如“application/json”)。 Web API 使用另一個格式 ...
[英]Is Microsoft.AspNet.WebApi.Client supported in .NET Core or not?
我目前正在嘗試使用 .NET Core 和 MediaTypeFormatters 中的 HttpClient 進行一些 JSON 格式設置。 特別是函數“ReadAsAsync(..., MediaTypeFormatter, ...)”( https://msdn.microsoft.com/d ...
[英]web api: add data to the HttpResponseMessage
我的web api中有一個動作,它返回一個HttpResponseMessage : 現在,我的問題是,如果發出請求並且請求的Content-Type是application/xml ,我應該使用xml formatter放置響應的主體。 有沒有辦法使用泛型類,讓框架根據請求的內容 ...
[英]text/plain Media Type not being accepted for WebApi v2
這個問題從IE9開始,對於POST請求, contentType必須是text/plain ,而application/json將不起作用。 我添加了moonscript並繼續使用contentType: text/plain 。 我還將自定義媒體類型添加到api中,如下面的多種表單所示 ...
[英]Custom MediaTypeFormatter (Serializer) for ApiController specific method
我有ApiController ,其中一個方法需要自定義序列化。 有大量的Session對象可以容納所有內容,而消費者不希望得到超過一半的內容,通常我可以使用[XmlIgnore()]來裝飾屬性並完成,但是這個對象在內部通過許多API傳遞並刪除這些會破壞這些機制。 另一種解決方案是 ...
[英]Web API modify incoming payload in formatter
所有, 我正在嘗試通過Web API修改傳入對象的有效負載。 當前,我正在使用一個自定義格式化程序,該格式化程序繼承自JsonMediaTypeFormatter並覆蓋了相關方法。 看起來像這樣: 我正在使用它來跟蹤通過API傳入的每個對象。 在所有這些發生之前,我有 ...
[英]How to format response in an async WebAPI method?
如果我有一個async Web API方法,那么Request對象為null(如在其他帖子中討論的id,例如這個 )。 似乎在這種情況下返回響應的最常見方法是使用類似的東西 但是格式化? 通常, Request對象處理它,因為它知道請求了什么,但如果我沒有Request對象,那么 ...
[英]What are the best practices for manual MediaTypeFormatter management in ASP MVC Web API?
我有 ASP MVC Web API 服務,我的方法應該以特定格式(JSON、XML 等)返回數據。 響應格式取決於方法,而不取決於客戶端首選項。 我使用HttpResponseMessage和ObjectContent並且需要為ObjectContent設置 MediaTypeFormatter ...
[英]Custom MediaTypeFormatter not being used for deserialization
我有一個簡單的MediaTypeFormatter像這樣: 像這樣在WebApiConfig連接: 和一個Web API控制器: 但是,當我使用GET(通過瀏覽器)測試控制器時,卻收到了null請求。 CanReadType觸發並返回true,但是ReadFromStr ...
[英]How to Customize json? How can override WriteToStreamAsync method in the MediaTypeFormatter for the customization of json Result
我有一個webApi應用程序,它是從現有Api遷移而來的,因為每個客戶端都需要json和xml結果(在URL http://localhost:1518/api/List?type=regions&format=json ),所以在我的應用程序我有一個用於xml和json結果的類 ...
[英]Extending from JsonMediaTypeFormatter to set customer headers doesn't work with http Accept header
我的目標是向每個傳出的JSON響應中添加某些自定義標頭。 為此,創建了一個從SetDefaultContentHeaders JsonMediaTypeFormatter擴展的類,並覆蓋了SetDefaultContentHeaders方法,如下所示: 然后,我將派生的媒體類型格式化程 ...
[英]Web API seems to be caching JsonFormatter with OData requests?
TL; DR :我的OData請求似乎一次擊中了我的自定義JsonFormatter,並且每個OData GET方法(每個控制器)僅擊中了一次,這導致“卡住”(緩存?)自定義格式。 我正在研究一個Web API項目,並且已經實現並注冊了自己的JsonMediaTypeFormatter ...
[英]Return List<object> in Csv format as response WCF C#
我想從我的WCF方法將類對象的列表作為csv文件返回。 我嘗試使用此處提供的MediaTypeFormatter實現自定義格式器 但是我無法在WCF服務方法中實現這一點。 有沒有一種方法可以在WCF中實現呢? 我可以以某種方式在ResponseFormat中設置自定義格式器,它將起作 ...