Given the following class,
public class Result
{
public bool Success { get; set; }
public string Message { get; set; }
}
I a
You can add this setting to Global.asax
, and it will be work everywhere.
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
//....
JsonConvert.DefaultSettings = () =>
{
var settings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
PreserveReferencesHandling = PreserveReferencesHandling.None,
Formatting = Formatting.None
};
return settings;
};
//....
}
}