Baama
Baama

Reputation: 2642

Binding Custom Object From Header Asp.Net Core WebApi

How do i bind an object from header. Am using the [FromHeader(Name = "Custom-Object")] but it seems to only be able to bind strings and sting arrays. Do i need to write custom binding or am i missing something here? I wonder why fromheader cannot bind complex object like frombody?

Upvotes: 6

Views: 5067

Answers (1)

Raj Kumar - rajkrs
Raj Kumar - rajkrs

Reputation: 1363

Write custom binder by using IModelBinder and IModelBinderProvider that should resolve your problem.

Upvotes: 1

Related Questions