You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a prototype Api using a simple model class inheriting Identifiable and a custom IResourceService (to avoid using EF) and tested the Post and primary Get methods. Everything worked great.
I then tried to change the model class to inherit Identifiable (to match our production system). The Gets work fine, but the Post threw exceptions. First, it threw a NullReferenceException in GetStringId before the Controller Action was called. I set the Id in the constructor and then it returned 403 Forbidden.
I also tested using Identifiable which worked as expected.
I created a demo solution (basic Asp.Net Core 2.1 Api only adding JsonApiDotNetCore) to demonstrate the problem. I made changes in Startup.cs, and added three Controllers (and related classes).
I set the Id in the constructor and then it returned 403 Forbidden
By setting the Id in the constructor, the controller believes the id was set by the client and since AllowClientGeneratedIds is disabled by default, that is why you received a 403.
Description
I created a prototype Api using a simple model class inheriting Identifiable and a custom IResourceService (to avoid using EF) and tested the Post and primary Get methods. Everything worked great.
I then tried to change the model class to inherit Identifiable (to match our production system). The Gets work fine, but the Post threw exceptions. First, it threw a NullReferenceException in GetStringId before the Controller Action was called. I set the Id in the constructor and then it returned 403 Forbidden.
I also tested using Identifiable which worked as expected.
I created a demo solution (basic Asp.Net Core 2.1 Api only adding JsonApiDotNetCore) to demonstrate the problem. I made changes in Startup.cs, and added three Controllers (and related classes).
You can find the demo solution at JsonApiDotNetCore-Bug-Reproduction.
Note that my-ints and my-guids work as expected, while my-strings fails with the exceptions above.
Environment
Visual Studio 2017 Professional 15.8.1
The text was updated successfully, but these errors were encountered: