I have a web API method, that is defined like this:
[HttpPost]
[Route("{id:int}/whatever")]
[AuthorizeClass]
public async Task<IHttpActionResult> functionName(int id, [FromBody] JToken data)
{
//Do something....
return Ok();
}
public class AuthorizeClass : AuthorizeAttribute
{
public override void OnAuthorization(HttpActionContext actionContext)
{
//Do something...
}
}
In the OnAuthorization
method I need to find the value of the id parameter, which seems to be held in the querystring.
I can find the whole string, but I want to specifically find it by its name, rather than deconstructing the query string - is this possible?
EDIT:
I have tried the answers in this question: Accessing QueryString in a custom AuthorizeAttribute
but they just return an empty array