Closed arknu closed 7 months ago
Hi there @arknu!
Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.
We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.
We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.
Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:
Closing this with explanation in the comments here: https://github.com/umbraco/Umbraco-CMS/pull/15883
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
13.2
Bug summary
I was trying to configure Newtonsoft.JSON to use parse dates as DateTimeOffset rather than DateTime in my controllers derived from UmbracoApiController. This should be a simple matter of having this code on startup:
Much to my surprise this didn't work.
After some digging, I discovered that Umbraco has an
UmbracoJsonModelBinder
that is used for anything that is an UmbracoApiController. And this class simply creates a newMvcNewtonsoftJsonOptions
rather than using the globally configured one: https://github.com/umbraco/Umbraco-CMS/blob/2fbda6e64ba4b2b2cfd84df92b253d1c8ede7cd5/src/Umbraco.Web.Common/ModelBinders/UmbracoJsonModelBinder.cs#L30-L32This issue is present in at least v12 as well, and probably v11, v10 and v9 as well.
Specifics
No response
Steps to reproduce
Try modifying the Newtonsoft JSON Options as above. Notice that they don't apply to an UmbracoApiController.
Expected result / actual result
The globally configured options should be respected