views:

768

answers:

1

What is the difference between using a WebGet attribute

[WebGet( ResponseFormat = WebMessageFormat.Xml )]

and manually setting the content type?

WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml";

I have a Silverlight app that is making this request to WCF. I'm looking at the traffic and the request/response for the ClientAccessPolicy.xml file looks exactly the same to me.

The problem is, manually setting the content type works fine in all browsers, but using WebGet will cause the Silverlight app to not be able to connect to the WCF services on FireFox only. It works in all other browsers. And again, doing it manually works fine in FireFox.

Doing it manually is a problem when unit testing, because WebOperationContext.Current is null during the test.

A: 

ResponseFormat is about ... the format of the response: XML vs. JSON.

ContentType is a header. Hopefully it's set to a value that corresponds to the response format.

John Saunders
Using WebMessageFormat.Xml will set the ContentType to application/xml also. But when it does this, Silverlight can't access WCF services anymore. I want to know what WebGet is doing differently that causes this behavior.
Josh Close
I don't know, I don't know SilverLight. Maybe try WebMessageFormat.Xml and set ContentType to "text/xml"
John Saunders