Skip to content

Identifiable<string> causes exceptions in Post #382

Closed
@Nihimon

Description

@Nihimon

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

  • JsonApiDotNetCore Version: 2.5.1
  • Other Relevant Package Versions: Microsoft.NETCore.App 2.1.0, Microsoft.AspNetCore.App 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions