webapi返回不带引号的字符串,解决自动加双引号的问题

   protected HttpResponseMessage GetByRequestId(string requestId)
        {
            var jsonResult = SerialPortUtil.GetByRequestId(requestId);
            if (!string.IsNullOrEmpty(jsonResult))
            {
                HttpResponseMessage responseMessage = new HttpResponseMessage { Content = new StringContent(jsonResult, Encoding.GetEncoding("UTF-8"), "text/plain") };
                return responseMessage;
            }
            else
            {
                return new HttpResponseMessage(HttpStatusCode.RequestTimeout);
            }
        }

返回自定义的 HttpResponseMessage 

posted @ 2019-09-05 17:06 _York 阅读(...) 评论(...) 编辑 收藏