コード例 #1
0
        protected async void Button1_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> db = new Dictionary <string, string>();
            SqlCommand    getUsersCredCmd  = new SqlCommand("SELECT [Login],[Password] FROM [Users]", sqlConnection);
            SqlDataReader sqlReader        = null;

            try
            {
                sqlReader = await getUsersCredCmd.ExecuteReaderAsync();

                while (await sqlReader.ReadAsync())
                {
                    db.Add(Convert.ToString(sqlReader["Login"]), Convert.ToString(sqlReader["Password"]));
                }
            }
            catch { }
            finally
            {
                if (sqlReader != null)
                {
                    sqlReader.Close();
                }
            }
            if (TextBox2.Text == db[TextBox1.Text])
            {
                HttpCookie login = new HttpCookie("login", TextBox1.Text);
                HttpCookie sign  = new HttpCookie("sign", SignGenerator.GetSign(TextBox1.Text + "bytepp"));
                Response.Cookies.Add(login);
                Response.Cookies.Add(sign);
                Response.Redirect("UserPage.aspx", false);
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie login = Request.Cookies["login"];
            HttpCookie sign  = Request.Cookies["sign"];

            if (login != null && sign != null)
            {
                if (sign.Value == SignGenerator.GetSign(login.Value + "bytepp"))
                {
                    return;
                }
            }
            Response.Redirect("Login.aspx");
        }