从标头Asp.Net Core WebApi绑定自定义对象

问题描述 投票:5回答:1

如何从标题绑定对象。我使用的是[FromHeader(Name = "Custom-Object")],但它似乎只能绑定字符串和sting数组。我需要编写自定义绑定还是我错过了什么?我想知道为什么fromheader不能像来自bodybody那样绑定复杂的对象?

c# attributes model-binding asp.net-core-webapi request-headers
1个回答
0
投票

使用IModelBinder and IModelBinderProvider编写自定义绑定器,以解决您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.