Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return raw string from REST service method

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

like image 316
bzamfir Avatar asked Feb 03 '12 16:02

bzamfir


1 Answers

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.

like image 165
carlosfigueira Avatar answered Nov 11 '22 03:11

carlosfigueira