I created a custom handler that looks like follow:
public class SitHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
Debug.WriteLine("Process request");
// Call the inner handler.
var response = await base.SendAsync(request, cancellationToken);
Debug.WriteLine("Process response");
return response;
}
}
and registered in the class WebApiConfig:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
//Delegating Handlers
config.MessageHandlers.Add(new SitHandler());
// Web API routes
config.MapHttpAttributeRoutes();
/*config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);*/
}
}
and have following route:
[RoutePrefix("")]
public class SignInController : Controller
{
[Route("", Name = "Default")]
public ActionResult Index()
{
return View();
}
}
Now when I start the server it show me the correct page as expected:

But the request does not goi throught the handler, why?
And what is an innerhandler?
// Call the inner handler.
var response = await base.SendAsync(request, cancellationToken);
Controllerand notApiController. What version of api.net-mvc are your using?