How to get the content of HttpWebResponseMessage

后端 未结 1 538
广开言路
广开言路 2021-01-14 17:30

I have a asp.net MVC razor C# application which has 1 controller and 1 POST function which accepts a parameter. And the function returns a HttpResponseMessage.



        
相关标签:
1条回答
  • 2021-01-14 17:50

    You're mixing up WebAPI and MVC.

    For WebAPI, the HttpResponseMessage (with Content = new StringContent("the string")) would work.

    For MVC, the syntax to return a string is (note the ActionResult return type and Content() call):

    public ActionResult Test() 
    {
        return Content("This is my output");
    }
    
    0 讨论(0)
提交回复
热议问题