Re: Auto login

  •  05-10-2006, 8:49 PM

    Re: Auto login

     ReneK :
     
    For the Global.asax error , I think you configure the IIS virtual directory to asp.net1.1 , try to check it and set it to asp.net2 .
     
    ----------- 
     
    How about this code :
     
    AutoLogin.Aspx?username=hello&password=world
     
    <%@ Page Language="C#" %>
    <%@ Import Namespace="CutePortal" %>
    <%@ Import Namespace="CutePortal.Model" %>
    <%@ Import Namespace="CutePortal.Web" %>
    <%@ Import Namespace="CutePortal.Utility" %>
    <%@ Import Namespace="CutePortal.SqlScopeDAL.Data" %>
    <script runat="server">
       
        override protected void OnLoad(EventArgs args)
        {
            base.OnLoad(args);
            string username = Request.QueryString["username"];
            string password = Request.QueryString["password"];
            if (string.IsNullOrEmpty(username))
                return;
            if (string.IsNullOrEmpty(password))
                return;
            if (!ValidateUser(username, password))
            {
                return;
            }
            System.Web.Security.FormsAuthentication.SetAuthCookie(username,false);
            int lobbyid = 1;
           
            Response.Redirect("CuteSoft_Client/CuteChat/CH_MainForm.Aspx?Location=Lobby&LocationId="+lobbyid);
        }
        public bool ValidateUser(string username, string password)
        {
            CutePortal.Model.Guest g = new CutePortal.Model.Guest();
            g.Name = username;
            g.Password = password;
            CutePortal.Business.Board f = new CutePortal.Business.Board();
            CutePortal.Model.User user = f.Login(g);
            if (user != null)
                return true;
            return false;
        }
     
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Auto Login Failed</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                Auto Login Failed
            </div>
        </form>
    </body>
    </html>
View Complete Thread