/// <summary> /// Called when [begin request]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void OnBeginRequest(object sender, EventArgs e) { HttpApplication context = sender as HttpApplication; if (string.IsNullOrEmpty(CookieHelper.GetBasicAuthCookie()) && BasicAuthenticationHelper.RequiresAuthentication(context.Request.Path)) { if (!IsAuthenticated(context)) { SendAuthChallengeHeader(context); } } }
/// <summary> /// Called when [authorize]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void OnAuthorize(object sender, EventArgs e) { HttpApplication context = sender as HttpApplication; if (BasicAuthenticationHelper.RequiresAuthentication(context.Request.Path)) { BasicUser bu = CookieHelper.GetBasicUser(); if (bu == null || !(BasicAuthenticationHelper.Authenticate(bu.UserName, bu.Password))) { SendNotAuthorizedHeader(context); } } }