开发者

Modify WCF 4.0 REST Web Service Response

开发者 https://www.devze.com 2023-01-28 23:10 出处:网络
I\'m relatively new to WCF, specifically the WCF 4 REST Online开发者_StackOverflow Template. I am testing a basic method:

I'm relatively new to WCF, specifically the WCF 4 REST Online开发者_StackOverflow Template.

I am testing a basic method:

[WebGet(UriTemplate = "Test")]
public string Test() 
{
    return "Test";
}

The response generated is:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hello World</string>

Is there any way to send back anything other than XML or JSON, or is there any way to modify the response?


You could return Stream; WCF won't apply formatting and you would be free to write whatever content you wanted to the Stream.

This article may help.

Edit:
Also, keep in mind that if you are going to use this method to serve up a file, for example, then you'll need to find some way to set the MIME type appropriately. This thread should give you some ideas. Personally, I prefer the Registry Read method suggested by @Serguei.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号