Return raw string from REST service method

僤鯓⒐⒋嵵緔 提交于 2019-11-30 23:47:36

问题


I have a REST service method written in C#, defined as below:

[WebGet(UriTemplate = "/{par1}/{par2}/{par3}")]
public string ProcessGet(string par1, string par2, string par3)
{
    return Execute(...);
}

It should return result as XML or JSON, based on one parameter (I generate the json and XML serialization)

How can I make this method to return the RAW string, just as I created it, without HTMLEncoding it?

Thank you


回答1:


Return it as a Stream - that causes the "raw" mode to be used and WCF will not touch your response. You can find more information at http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-web.aspx.



来源:https://stackoverflow.com/questions/9132281/return-raw-string-from-rest-service-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!