WCF REST WebService content type is wrong

前端 未结 1 694
死守一世寂寞
死守一世寂寞 2021-01-25 09:05

I created a simple REST Service using the WCF REST Template 40(CS) which is working just fine. There only is a problem that the response uses \"application/json\" as content typ

1条回答
  •  伪装坚强ぢ
    2021-01-25 09:39

    If you want to return an arbitrary content from a WCF REST service, you need to use the Raw programming model - http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-web.aspx. The template you used defines the endpoint using the service route, so it's all set up for you. Now you need to define the operation returning a Stream parameter, and set the appropriate content type in the operation: WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";

    0 讨论(0)
提交回复
热议问题