public void TestMethod1()
 {
     UserInfo user = new UserInfo();
     user.find();
     Assert.IsNotNull(user.User);
     Console.WriteLine("user is " + user.User);
     user.save();
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (!__bxmlCheck0.Checked)
            {
                __bxmlLabel.Visible = true;
                return;
            }

            UserInfo userInfo = new UserInfo();
            userInfo.find();
            userInfo.setReadNow();
            userInfo.save();
            Response.Redirect(UserInfo.ProtectedPageUrl());
        }
        private void AuthenticateRequest(Object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            HttpContext context = app.Context;
            HttpRequest Request = context.Request;

            String username = "";

            try
            {
                username = context.User.Identity.Name;
            }
            catch (Exception)
            {

            }

            log.Debug(username + " AuthenticateRequest Request.Url.LocalPath = " + Request.Url.LocalPath);
            log.Debug(UserInfo.getUserId() + " AuthenticateRequest Request.Url.ProtectedPath = " + UserInfo.ProtectedPageUrl());
            if (!Request.Url.LocalPath.Equals(UserInfo.ProtectedPageUrl()))
            {
                log.Debug("return");
                return;
            }
            log.Debug("continue");

            HttpResponse Response = app.Context.Response;

            UserInfo userInfo = new UserInfo();

            userInfo.find(username);
            Boolean readAgreement = userInfo.hasReadTheAgreement();

            log.Debug(UserInfo.getUserId() + " readAgreement = " + readAgreement);
            if (IsPost(context) && !IsAccessingLoginPage(context, UserInfo.MessageUrl()))
            {
                if (!readAgreement)
                {
                    // Create a FormState instance with the current form post contents and store a 'pointer'
                    // to this instance in a cookie, so we can find it again after relogin.
                    FormState state = FormState.Create(context);
                    if (state != null)
                    {
                        HttpCookie cookie = new HttpCookie(CookieName, state.StateId);
                        cookie.HttpOnly = true;
                        context.Response.Cookies.Add(cookie);
                    }
                    Response.Redirect(UserInfo.MessageUrl());
                }
            }
        }
    /*    void Application_PostMapRequestHandler(object source, EventArgs e)
       {
      HttpApplication app = (HttpApplication)source;

      if (app.Context.Handler is IReadOnlySessionState || app.Context.Handler is IRequiresSessionState) {
         // no need to replace the current handler
         return;
      }

      // swap the current handler
      app.Context.Handler = new MyHttpHandler(app.Context.Handler);
       }

       void Application_PostAcquireRequestState(object source, EventArgs e)
       {
           HttpApplication app = (HttpApplication)source;

           MyHttpHandler resourceHttpHandler = HttpContext.Current.Handler as MyHttpHandler;

           if (resourceHttpHandler != null)
           {
               // set the original handler back
               HttpContext.Current.Handler = resourceHttpHandler.OriginalHandler;
           }

           // -> at this point session state should be available

           appSession = app.Session;
       }*/
    /// <summary>Occurs when a security module has established the identity of the user.</summary>
    private void AuthenticateRequest(Object sender, EventArgs e)
    {
        HttpApplication app = (HttpApplication) sender;
            HttpContext context = app.Context;
            HttpRequest Request = context.Request;

            if (!Request.Url.LocalPath.Equals(UserInfo.ProtectedPageUrl())) return;

            HttpResponse Response = app.Context.Response;

            UserInfo userInfo = new UserInfo();
            userInfo.find();
            userInfo.Url = Request.Url.AbsolutePath;
            userInfo.save();
            Boolean readAgreement = userInfo.hasReadTheAgreement();

        if (!readAgreement)
            {
                FormState state = FormState.Create(context);
                if (state != null)
                {
                    HttpCookie cookie = new HttpCookie(CookieName, state.StateId);
                    cookie.HttpOnly = true;
                    context.Response.Cookies.Add(cookie);
                }
                Response.Redirect(UserInfo.MessageUrl());
            }
    }