Tuesday, February 2, 2010

check for user authentication and session expiry


To check for user authentication and session expiry
On POPUP PAGE
Call this function on Pageload.
IsUserAuthorizedinPopUp(Convert.ToString(Session["UserId"]));
/// 
    /// To check for user authentication and session expiry
    /// 
    /// 

    /// 
    public bool IsUserAuthorizedinPopUp(string userId)
    {
        bool continueFlag = false;
        if ((userId == "") || (userId == "0"))
        {
           RadAjaxPanel1.ResponseScripts.Add("CancelEdit();");
        }
        else
        {
            continueFlag = true;
        }
        return continueFlag;
    }
On Nornal page (defined in pagebase)
Call this function on Pageload.

IsUserAuthorized(Convert.ToString(Session["UserId"]));
/*'----------------------------------------------------------------
        ' Function Name     : IsPublicUserAuthorized
        ' Purpose           : This method checks authentication for the Public users
        ' Input             : userId as String
        ' return output     : True if authorized user else False
        '----------------------------------------------------------------*/
        public bool IsUserAuthorized(string userId)
        {
             /* Disable client-side caching of web pages such that Browser Back/Forward button usage does
            ' not cause any issues*/
            bool continueFlag=false; 
            DisableBrowserBack();
            if ((userId == "") || (userId == "0"))
            {
                 Response.Redirect("TIOLogin.aspx");
            }
            else
            {
                continueFlag =true;
            }
            return continueFlag; 
        }

No comments:

Post a Comment