JsonModelBinder 2.0.0
See the version list below for details.
dotnet add package JsonModelBinder --version 2.0.0
NuGet\Install-Package JsonModelBinder -Version 2.0.0
<PackageReference Include="JsonModelBinder" Version="2.0.0" />
paket add JsonModelBinder --version 2.0.0
#r "nuget: JsonModelBinder, 2.0.0"
// Install JsonModelBinder as a Cake Addin #addin nuget:?package=JsonModelBinder&version=2.0.0 // Install JsonModelBinder as a Cake Tool #tool nuget:?package=JsonModelBinder&version=2.0.0
JsonModelBinder
This library provides an explicit json model binder to allow json serialized parts in a multipart-formdata request of a .Net-Core controller action.
Install-Package JsonModelBinder
Now you can, for example, have a file upload action with additional data about the upload as a json structure. Then your controller upload action would look like this:
[HttpPost]
public IActionResult Upload([ModelBinder(BinderType = typeof(JsonModelBinder))] JsonModel model, IFormFile file) {
// model is now deserialized from the formdata-part named 'model'
// file represents the file sent in the formdata-part named 'file'
return Ok();
}
An valid request for the above action would be a POST with content-type: multipart/form-data
with two parts specified: model
(the json string according to the model type) and file
(the form-data file). The model binder will take care of the deserialization process and will provide you with a concrete model class as specified in the controller action signature.
The JsonModelBinder
will use the defined MvcJsonOptions
from startup (.AddMvc().AddJsonOptions(...)
). If these options are not available the default Json.Net settings will be used to deserialize the model.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp1.0 is compatible. netcoreapp1.1 was computed. netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
-
.NETCoreApp 1.0
- Microsoft.AspNetCore.Mvc (>= 1.0.0)
- Microsoft.Extensions.Options (>= 1.0.0)
- Microsoft.NETCore.App (>= 1.0.5)
- Newtonsoft.Json (>= 12.0.2)
-
.NETCoreApp 2.0
- Microsoft.AspNetCore.Mvc (>= 2.0.0)
- Microsoft.Extensions.Options (>= 2.0.0)
- Newtonsoft.Json (>= 12.0.2)
-
.NETCoreApp 3.0
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.