How to return raw string with ApiController?

前端 未结 6 860
萌比男神i
萌比男神i 2020-11-29 21:49

I have an ApiController that serves XML/JSON, but I would like one of my actions to return pure HTML. I tried the below but it still return XML/JSON.

public          


        
6条回答
  •  萌比男神i
    2020-11-29 22:28

    We must strive not to return html but pure data from our API's and format data accordingly in the UI, but maybe you can use:

    return this.Request.CreateResponse(HttpStatusCode.OK, 
         new{content=YourStringContent})
    

    it works for me

提交回复
热议问题