Click here to Skip to main content
16,020,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want code web api controller or WebApiConfig.cs only.
no any code for client side
Posted
Comments
Maciej Los 8-May-15 5:31am    
Not a question at all!!

1 solution

Probably not the best solution, but I needed to force a JSON result in a recent project.

Quick and dirty solution was to add the following to the Application_Start method in the global.asax:

C#
GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();


This removes the XML formatter, so the app falls back to JSON.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900