I have a controllers with GET/POST methods and i was wondering if it's possible to intercept the object before reach the POST method on Controller.
Here is my method on Controller:
[Route("{type}")]
[HttpPost]
public HttpResponseMessage Save(string type, [FromBody] Message message)
{
....
return Request.CreateResponse((HttpStatusCode)200, result);
}
Is possible to intercept the object Message before method Save() has been called? I've created a DelegatingHandler but it's not working.
Here is how i've added the route:
IHttpRoute route = GlobalConfiguration.Configuration.Routes.CreateRoute(
routeTemplate: "api/message/{type}",
defaults: new HttpRouteValueDictionary("route"),
constraints: null,
dataTokens: null,
handler: new ValidationHandler());
GlobalConfiguration.Configuration.Routes.Add("MyRoute", route);
Any ideas how can i do it?
If you have already created your
DelegatingHandler
you will need to configure it as follows: