How do I return an empty response

Topics: Web Api
Dec 23, 2011 at 11:22 AM
Edited Dec 23, 2011 at 12:32 PM

Hi

How do I return a response that doesn't have a body, but still has some header information ?

If I do:

 

        public HttpResponseMessage Sample()
        {
            var response = new HttpResponseMessage(HttpStatusCode.Accepted);
            response.Headers.Location = uri;
            return response;
        }

 

I get a null pointer exception

If I do:

 

        public HttpResponseMessage<string> Sample()
        {
            var response = new HttpResponseMessage<string>(HttpStatusCode.Accepted);
            response.Headers.Location = uri;
            return response;
        }

 

I get:

 

<?xml version="1.0" encoding="utf-8"?><string a:nil="true" xmlns:a="http://www.w3.org/2001/XMLSchema-instance"/>

 

in the body of my response....

Merry Christmas

Søren