I've created 2 projects:
- Normal, basic ASP.NET MVC 4 application
- Basic ASP.NET WebAPI application
What I did is I added my custom message handler, derived from DelegatingHandler
to both of them. Here it is:
public class MyHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
return base.SendAsync(request, cancellationToken);
}
}
I registered it in global.asax
in both:
GlobalConfiguration.Configuration.MessageHandlers.Add(new MyHandler());
I put a breakpoint in
return base.SendAsync(request, cancellationToken);
The difference between ASP.NET MVC and ASP.NET WebAPI is that when I call ASP.NET MVC application (http://localhost:4189/Something
) the breakpoint is not triggered. When I call Web API however (http://localhost:7120/api/values
), the breakpoint is triggered.
Why is that? Are there any differences in those application types execution flows?
In addition, when I try to request normal Controller
, not ApiController
of WebAPI application, like http://localhost:7120/Home
, the break point is not triggered.