Search code examples
asp.net-mvc-4logoutsimplemembership

How can I kick the user if I change IsConfirmed column?


I use ASP.NET SimpleMembership..

My scenario;

The user login and then I change IsConfirmed column to false on webpages_Membership table.. And the user try to change page, the login page seems to the user..


Solution

  • I user Application_AuthenticateRequest in Global.asax.. Because my application needs authenticate on all pages..

    protected void Application_AuthenticateRequest()
            {
                if (WebSecurity.IsAuthenticated)
                {
                    bool isConfirmed = (..your codes here..)
                    if (isConfirmed == false)
                    {
                        WebSecurity.Logout();    
                    } 
                }
            }