locked
HandleUnauthorizedRequest not being invoked under IIS RRS feed

  • Question

  • User-2007097502 posted

    Hello,

    I have written a custom AuthorizeAttribute.

    I overrided both AuthorizeCore and HandleUnauthorizedRequest (below)

    In VS it works very nice and redirects to a login view.

    Under IIS it just shows 401 error. What am i missing?

    Thanks,

    Roy

    protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)

    {
    if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
    {
    base.HandleUnauthorizedRequest(filterContext);
    }
    else
    {
    filterContext.Result = new RedirectToRouteResult(
    new RouteValueDictionary(new
    {
    controller = Const.CONTROLLER_AUTHORIZE,
    action = Const.ACTION_SHOW_AUTHORIZE
    }));
    }

    Wednesday, July 17, 2013 3:53 PM

Answers

  • User-2007097502 posted

    Hello,

    The lines:

    if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
    {
    base.HandleUnauthorizedRequest(filterContext);
    }

    Were my bug.

    Thanks,

    Roy.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 18, 2013 4:48 PM

All replies

  • User-2007097502 posted

    Hello,

    The lines:

    if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
    {
    base.HandleUnauthorizedRequest(filterContext);
    }

    Were my bug.

    Thanks,

    Roy.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 18, 2013 4:48 PM
  • User-166373564 posted

    Hi roy

    if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
    {
    base.HandleUnauthorizedRequest(filterContext);
    }

    Were my bug.

    Glad that you've solved this issue by yourself, and thanks for your quick feedback, if you have any issue in your programming, welcome to post it to our asp.net forums,

    Best regards

    Angie xu

     

    Tuesday, July 23, 2013 9:20 PM