Facing Error 500.19 when add a AuthorizeAttribute

47 Views Asked by At

I'm trying to add a custom AuthorizeAttribute to my MVC website,i check the tutorial on web and make a simple one.

    public class HandAuthorizeAttribute : AuthorizeAttribute
{
    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        try
        {
            HttpCookie cookieUser = httpContext.Request.Cookies["empNo"];
            if (cookieUser == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        catch (Exception ex)
        {
            return false;
        }


    }

    protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
    {
        filterContext.HttpContext.Response.Redirect("/User/Login");
        //base.HandleUnauthorizedRequest(filterContext);
    }
}

it was compiled without error but when i try to test it it show a 500.19 error on iss, showed that the web.config has problem, but when i removed the authorize attribute it was okay. ERROR

0

There are 0 best solutions below