Open RodrigoSedano opened 3 years ago
Hello, it already supports netstandard2.0 (multiple TargetFrameworks) (but in asp.net core there is a native way to bind models in api actions, so there it is used mostly to send multipart formatted models)
пт, 17 сент. 2021 г. в 13:14, RodrigoSedano @.***>:
Hi,
Is there any plan to add support for .Net Core, .Net 5, .Net 6?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/iLexDev/ASP.NET-WebApi-MultipartDataMediaFormatter/issues/32, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJ576TAEHVRVEMINYD5ZGLUCMIHFANCNFSM5EGVYY4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Hi, We have migrated our we application from .net 4.8 to .Net 5 and many of the requests are failing. Before (.Net 4.8) we had this configuration
public static void Register(HttpConfiguration config)
{
var json = config.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
json.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
config.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter(new MultipartFormatterSettings()));
......
}
and it seems that the FormMultipartEncodedMediaTYpeFormatter was converting the properties in the request to the correct datatype.
We have request where a "0" string should be converted to 0 int, date string "30-12-2021" string should be converted to 30-12-2021 datetime, "" guid should be converted to Guid Empty and so on.
My question is how we can add FormMultipartEncodedMediaTYpeFormatter so our we application requests works as before.
Hi, I am sorry but this formatter cannot be used in asp.net core for model binding. It is possible to rewrite it to support new interfaces as described here - https://docs.microsoft.com/en-us/aspnet/core/web-api/advanced/custom-formatters?view=aspnetcore-5.0 but, I think it is better to stick with native solutions whenever we can. It should not be very hard to migrate your code to use native model binder - https://dottutorials.net/dotnet-core-web-api-multipart-form-data-upload-file/
Please, let me know in case of any issues.
Hi,
Is there any plan to add support for .Net Core, .Net 5, .Net 6?