How do I get JSON from a self-hosted WCF 4.5 service?
I'm using Fiddler2 to send requests with "Content-Type: application/json" (also tried "Content-Type: application/javascript") but I keep getting XML.
In combination with setting "AutomaticFormatSelectionEnabled = true" on my WebHttpBehavior I still get XML and when using "Content-Type: application/json" the server won't respond at all (Then I get error 103)
I have enabled CrossDomainScriptAccessEnabled on my WebHttpBinding and I'm using a WebServiceHost in a console host.
The service is very simple:
[ServiceContract]
public interface IWebApp
{
[OperationContract, WebGet(UriTemplate = "/notes/{id}")]
Note GetNoteById(string id);
}
I've also tried setting AutomaticFormatSelectionEnabled to false and using ResponseFormat = WebMessageFormat.Json in my service-contract but that also result in "error 103" with no further info.
I've turned of customErrors and set FaultExceptionEnabled, HelpEnabled to true (not sure if that would do anything about this but just to make sure I've tried it all)
Am I missing a dll or something else?