Reputation: 1562
I am migrating from a Java Jax-Rs API into ASP.NET. I have custom header params that I pass into the API.
I couldn't find the way to do the same in ASP.NET.
This is what I have so far:
[HttpPost]
public String login()
{
return "works";
}
I searched in every tutorial I found and couldn't find any mention to this.
Upvotes: 2
Views: 4073
Reputation: 63126
ASP.NET Core does support Model Binding from the header, so, to get similar to your action listed you could use.
[HttpPost]
public String login([FromHeader(Name="usuario")] string usuario, [FromHeader(Name="pass")] string pass))
{
return "works";
}
You could then interact with the properties as desired.
Upvotes: 6