dotariel
dotariel

Reputation: 1594

Modify WCF 4.0 REST Web Service Response

I'm relatively new to WCF, specifically the WCF 4 REST Online 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?

Upvotes: 2

Views: 466

Answers (1)

Randolpho
Randolpho

Reputation: 56381

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.

Upvotes: 1

Related Questions