Authentication logic doesn't work on Azure hosted ASP.NET MVC website

119 Views Asked by At

Please bear with me as I'm a noob in Azure technology. I have one ASP.NET MVC application hosted on Azure where forms authentication has been implemented. The application works fine locally. But on Azure hosted website the session object in AuthorizationContext becomes null. The if condition mentioned below in the custom authorize attribute always turns out to be true.

    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        if (filterContext.HttpContext.Request.IsAuthenticated && filterContext.HttpContext.Session["UserInfo"] == null)
        {
              -------  Redirect to login page -----------------------
        }

        -----------------------------------------------
    }

Also filterContext.HttpContext.Request.IsAuthenticated is always false.

After searching a lot on internet I have not been able to find any clue about why this is happening. Is there any setting I'm missing in Azure configuration? Thanks in advance.

0

There are 0 best solutions below