I set JsConfig in Application_Start method in my asp net mvc application
protected void Application_Start()
{
JsConfig.DateHandler = JsonDateHandler.ISO8601;
JsConfig.EmitCamelCaseNames = true;
}
and then I want to use extension method ToJson in my service method, for example
public string testMethod{
//here code
var obj = new TestObj{
Id = 1,
CurrentDate = DateTime.Now
}
return obj.ToJson();
}
and then I look a result and I see that json result in PascalCase and date in following format Date(123455678990)
, but before I set in config for use the camelCase and utc format date
but I set config in my service method, for example:
public string testMethod{
//here code
JsConfig.DateHandler = JsonDateHandler.ISO8601;
JsConfig.EmitCamelCaseNames = true;
var obj = new TestObj{
Id = 1,
CurrentDate = DateTime.Now
}
return obj.ToJson();
}
I get the result that I want
Is it possible to set JsConfig properties on start my application?