返回类型改为HttpResponseMessage类型
1 [Route("api/TestControllers/test")] 2 [HttpGet] 3 public HttpResponseMessage Test() 4 { 5 HttpResponseMessage responseMessage = new HttpResponseMessage { Content = new StringContent("你要返回的字符串", Encoding.GetEncoding("UTF-8"), "text/plain") }; 6 7 return responseMessage; 8 }