从REST服务方法返回原始字符串 [英] Return raw string from REST service method

查看:162
本文介绍了从REST服务方法返回原始字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C#编写的REST服务方法,定义如下:

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(...);
}

它应该基于一个参数以XML或JSON的形式返回结果(我生成了json和XML序列化)

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

如何使此方法返回RAW字符串(就像我创建的那样),而无需HTMLEncoding?

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

谢谢

推荐答案

将其作为 Stream -导致使用原始模式,WCF将不会触摸您的响应。您可以在 http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-web.aspx

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.

这篇关于从REST服务方法返回原始字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆