Closed Exagram closed 3 years ago
For one endpoint I am required to handle different POST payload types:
Example endpoints: POST /api/message with payload { type: people, profile { ... } } POST /api/message with payload { type: invoice, lines: [ ... ] }
POST /api/message
{ type: people, profile { ... } }
{ type: invoice, lines: [ ... ] }
I found an ASP.NET Core Web API 2 solution but I am not using Core: https://docs.microsoft.com/en-us/aspnet/core/mvc/advanced/custom-model-binding?view=aspnetcore-2.2. Second I am looking for an automatic approach such as: if (modelType.Equals("people") DefaultBuiltinModelBinder.Bind<PeopleModel>(model). In contrast the tutorial provides a manual solution.
if (modelType.Equals("people") DefaultBuiltinModelBinder.Bind<PeopleModel>(model)
Related: https://github.com/aspnet/Mvc/issues/3722
Thanks for contacting us. This repo is in maintenance only mode and we won't implement new features in it. We only fix critical bugs and security issues.
For one endpoint I am required to handle different POST payload types:
Example endpoints:
POST /api/message
with payload{ type: people, profile { ... } }
POST /api/message
with payload{ type: invoice, lines: [ ... ] }
I found an ASP.NET Core Web API 2 solution but I am not using Core: https://docs.microsoft.com/en-us/aspnet/core/mvc/advanced/custom-model-binding?view=aspnetcore-2.2. Second I am looking for an automatic approach such as:
if (modelType.Equals("people") DefaultBuiltinModelBinder.Bind<PeopleModel>(model)
. In contrast the tutorial provides a manual solution.Related: https://github.com/aspnet/Mvc/issues/3722