<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
I solved this problem by changing the
automaticFormatSelectionEnabled="false"
attribute of the standardEndpoint element. I changed it to false to force it to use the format I am declaring as an attribute of my functions. If you set it true, it will let the client decide which format to use like what is happening in FireFox.
kgdev
Member
2 Points
5 Posts
WCF REST service returns XML for FireFox s/b JSON
Oct 13, 2011 05:51 PM|LINK
I have a WCF REST application designed to return JSON.
From IE and CHROME, my request returns JSON (as it should).
From FireFox, the same request retuns XML, which is the problem.
I need to get it to return JSON for all browsers.
The POST header varies from CHROME and FireFox.
FireFox POST header:
SleepyCrat
Member
2 Points
1 Post
Re: WCF REST service returns XML for FireFox s/b JSON
Nov 14, 2011 07:56 PM|LINK
<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <standardEndpoints> <webHttpEndpoint> <!-- Configure the WCF REST service base address via the global.asax.cs file and the default endpoint via the attributes on the <standardEndpoint> element below --> <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/> </webHttpEndpoint> </standardEndpoints> </system.serviceModel>I solved this problem by changing the
automaticFormatSelectionEnabled="false"
attribute of the standardEndpoint element. I changed it to false to force it to use the format I am declaring as an attribute of my functions. If you set it true, it will let the client decide which format to use like what is happening in FireFox.
Helpful article explaining this attribute
http://blogs.msdn.com/b/endpoint/archive/2010/01/18/automatic-and-explicit-format-selection-in-wcf-webhttp-services.aspx
-SleepyCrat
REST Json WCF
kgdev
Member
2 Points
5 Posts
Re: WCF REST service returns XML for FireFox s/b JSON
Dec 07, 2011 04:40 PM|LINK
Thank you, SleepyCrat.
I have been reassigned through the end of the year to a different project, but plan to resume work on this one in January 2012.
I will try your suggestion at that time and report my results.
Thanks again!! for responding.
Bob
REST Json WCF