This project is read-only.

A very basic question about output formatting

Topics: Web Api
Dec 15, 2011 at 7:03 PM

I have read that providing a Stream object as a method output results in a raw output different (eventually than) xml/json.

I am testing the following:

[WebGet(UriTemplate = "{id}")]
        public System.IO.Stream Get(string id)
                WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain";
                WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
                byte[] data = System.Text.Encoding.UTF8.GetBytes("TESTING ...");
                MemoryStream output =  new System.IO.MemoryStream(data);
                WebOperationContext.Current.OutgoingResponse.ContentLength = data.Length;
                output.Seek(0, System.IO.SeekOrigin.Begin);
                return output;


But I am getting a blank output... nothing (testing from IE). Under fiddler the output is still  blank but I get a 200 (OK) result.

Am I missing something or doing something wrong?

I appreciate your help...

Thank you...