We had similar issues at our end too when we added some serializer settings to startup, it was interfering with Optimizely forms. To address this we have removed serializer settings from startup which fixes the Optimizely forms.
We then have a custom result object class inheriting JsonResult where we specify the serializer settings and then use that as part of action method.
You can customize this class per your need. Then use CustomJsonSerializerResult instead of JsonResult as a return type.
public class CustomJsonSerializerResult : JsonResult public JsonSerializerSettings Settings { get; private set; } public override void ExecuteResult(ActionContext context) HttpResponse response = context.HttpContext.Response; var scriptSerializer = JsonSerializer.Create(this.Settings); using (var sw = new StringWriter()) |
I ended up removing the 'UseNewtonsoftSerialization' and just changing our 'react'-frontend to handle enums as ints instead.
That was the only main change that affected us.
I still needed to use the [JsonFormatter] attribute and the 'JsonFormattedResult' to format the json input/output properly.
Do note that creating a new JsonSerializerSettings
object every time might affect performance, so better create it statically once 👍
I want to use UseNewtonsoftSerialization for my custom Api Controllers.
This setting some how also affects loading of form data in backend when viewing form submissions.
If I remove the UseNewtonsoftSerialization the form submissions data starts working correctly again.
Any ideas?