Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odata DateTime TimeZone issue on PUT method after migration from .net4.7 to .net6 #512

Open
MADzO opened this issue Mar 3, 2022 · 10 comments
Assignees
Labels

Comments

@MADzO
Copy link

MADzO commented Mar 3, 2022

The whole explanation can be found here: https://stackoverflow.com/questions/71342051/odata-datetime-timezone-issue-on-put-method-after-migration-from-net4-7-to-net

@julealgon
Copy link
Contributor

@MADzO Please check if your route is being detected as an OData route. Enable the route debugging middleware and navigate to /$odata. Post the results here.

@MADzO
Copy link
Author

MADzO commented Mar 3, 2022

image
It is part of the OData Endpoint Mappings

@julealgon
Copy link
Contributor

@MADzO can you confirm which of those endpoints is the one you are targeting with the request?

@MADzO
Copy link
Author

MADzO commented Mar 3, 2022

Yeah sure.
It is visible also on the picture on stackoverflow.
image

@julealgon
Copy link
Contributor

I wonder if this is somehow related to this:

@xuzhg
Copy link
Member

xuzhg commented Mar 4, 2022

@MADzO Basically, i didn't fully understand your scenario. I created a sample at https://github.com/xuzhg/WebApiSample/tree/main/v8.x/TimeZoneSamples, can you make it failing or we can set up a meeting to sync it?

@MADzO
Copy link
Author

MADzO commented Mar 4, 2022

@xuzhg just send me a teams meeting and I can explain in detail. In meanwhile what you can see from the pictures is that same request with same data received in the old net4.7 and in the new .net6 solutions, has different values for the properties of type DateTime in the odata controller. Just check the values in the watch on the second picture in the very bottom and you will see it.

@xuzhg
Copy link
Member

xuzhg commented Mar 4, 2022

Sent in email

@MADzO
Copy link
Author

MADzO commented Mar 5, 2022

First of all @xuzhg thanks for the help and flexibility. Really apricate it.
Secondly we did conclude that if you do not have [FromBody] attribute in front of your complex parameter in POST/PUT method, OData will not even consider it as Odata parameter. That means that Odata serializer/deserializer will not be runed at all.
Also have it in the mind that OData works only with application/json content type.

@julealgon
Copy link
Contributor

Secondly we did conclude that if you do not have [FromBody] attribute in front of your complex parameter in POST/PUT method, OData will not even consider it as Odata parameter. That means that Odata serializer/deserializer will not be runed at all.

@MADzO consider annotating your controller or assembly with the [ApiController] attribute. This changes a few inference rules in the framework, including "treating complex types as [FromBody] by default". It is a very useful attribute for pure API projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants