反斜線造成Client端收到參數,反序列化JSON失敗
會因為多餘的反斜線造成Client端收到時,反序列化JSON失敗,
只要將API回傳參數改為HttpResponseMessage物件就可以
程式碼如下
- 回傳改為HttpResponseMessage物件
#region 取得設定
[Route("api/GetIDList/")]
[HttpGet]
public HttpResponseMessage GetIDList()
{
HttpResponseMessage httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK);
httpResponseMessage.Content = new StringContent(sJsonString, System.Text.Encoding.UTF8, "application/json");
return httpResponseMessage;
}
#endregion
沒有留言:
張貼留言