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

Does the JsonModelBinder work with dot net core 2 #1

Closed
functional-brew opened this issue Jul 29, 2018 · 3 comments
Closed

Does the JsonModelBinder work with dot net core 2 #1

functional-brew opened this issue Jul 29, 2018 · 3 comments

Comments

@functional-brew
Copy link

functional-brew commented Jul 29, 2018

Hi,

I saw the reference to this library at a StackOverflow question.

Does this library work with dot net core 2, as I always get null value for the parameter decorated with
the [ModelBinder(BinderType = typeof(JsonModelBinder))] controller action method.

I had created an empty project and then installed the library via Nuget.

@BrunoZell
Copy link
Owner

Yes, I myself had used it with target framework netcoreapp2.0. Make sure your request looks like in the example from StackOverflow.

As an alternative, you can try to use Patrice Cotes method and don't use this NuGet package at all as it's already build in.

@functional-brew
Copy link
Author

TheInsaneBro, Thanks a ton rechecked everything from the post and viola!! I can see the library in action now.

In ReadMe file, you have mentioned adding (.AddMvc().AddJsonOptions(...)) to startup.cs
It would be great if you can help me with an example for adding the config?

@BrunoZell
Copy link
Owner

Sure. In your Startup.cs in ConfigureServices:

services.AddMvc()
    .AddJsonOptions(options =>
        options.SerializerSettings.Converters.Add(new StringEnumConverter())
        // And do other configurations for Newtonsofts JSON.Net
    );

Make sure to add the nuget package Microsoft.AspNetCore.Mvc.Formatters.Json (or Microsoft.AspNetCore.All)

Could have probably made that more clear in the readme.

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

No branches or pull requests

2 participants