using System;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;
public class SampleApiInterceptorAttribute : ActionFilterAttribute
{
public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
{
string requestInfo = $"{DateTime.Now}: Request from {actionContext.Request.RequestUri}";
Console.WriteLine(requestInfo);
await base.OnActionExecutingAsync(actionContext, cancellationToken);
}
public override async Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
{
string responseInfo = $"{DateTime.Now}: Response to {actionExecutedContext.Request.RequestUri}";
Console.WriteLine(responseInfo);
await base.OnActionExecutedAsync(actionExecutedContext, cancellationToken);
}
}