How to implement AuthorizationContext attribute on WebApi?
<p>I'm trying to implement password expiry policy and found a good <a href="https://joeylicc.wordpress.com/2013/08/19/implement-password-expiration-check-in-asp-net-mvc/" rel="nofollow noreferrer">blog showing an example</a> - but that is in MVC. I'm trying to implement it for WebApi2. I expected WebApi to have similar functionality but so far have failed to locate the right namespaces / methods to call. </p>

<p>Relevant part of the code:</p>

<pre><code>public override void OnAuthorization(AuthorizationContext filterContext)
{
    if (!filterContext.ActionDescriptor.IsDefined(typeof(SkipPasswordExpirationCheckAttribute), inherit: true)
        &amp;&amp; !filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(SkipPasswordExpirationCheckAttribute), inherit: true))
        {
            ...

            if (timeSpan.Days &gt;= _maxPasswordAgeInDay)
            {
                ...

                filterContext.HttpContext.Response.Redirect(urlHelper.Action("ChangePassword", "Account", new { reason = "passwordExpired" }));
            }
        }

    base.OnAuthorization(filterContext);
}
</code></pre>

<ol>
<li><p>On WebApi, the override method signature is <code>OnAuthorization(HttpActionContext actionContext)</code> instead of <code>(AuthorizationContext filterContext)</code> - how do I check for <code>SkipPasswordExpirationAttribute</code> using actionContext? </p></li>
<li><p>Once I decide the password has expired, what action should I take? I don't suppose I can "redirect" user from WebApi as that doesn't make any sense.</p></li>
</ol>