Web service returning XML instead of JSON

I’m designing a web service (asmx) using the .NET framework 3.5 on an MVC site with the requirement to return JSON. Using some basic tutorials and the templates Visual Studio provides i was able to get a working model running on my laptop. When I deployed the solution to the server the results came back as XML.

I found the solution here. Since I am using .NET 3.5 for my web service, the handlers for the asmx  are not included in the machine.config. Adding the following line under system.webServer fixed this issue.

        &lt;add name="ScriptHandlerFactory"
             verb="*" path="*.asmx"
                 System.Web.Extensions, Version=, Culture=neutral, 
             resourceType="Unspecified" /&gt;

(Views: 307)

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.