本文介绍了想在我的登录页面上定义角色和身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个登录页面我想要的东西1我想要定义角色nad第二次使我的代码认证soo没有人可以从url访问。
请帮助我
i have made a login page i want to thing in it 1st i want to define roles nad 2nd make my code authentication soo no one can access from url.
please help me for that
try
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Administrator.LENOVO-74FE9906\Desktop\Orignal Project Part 1\Inventory Management System\IMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
string query = "SELECT [user].* FROM [user] where u_name='" + txtusername.Text + "' and pwd='" + txtpassword.Text + "'";
SqlCommand com = new SqlCommand(query, con);
con.Open();
if (txtusername.Text == "admin")
{
if (com.ExecuteReader().HasRows)
{
Response.Redirect("index.html");
Label3.Text = "successfully";
}
else
{
Label3.Text = "not successfully";
txtusername.Text = "";
txtpassword.Text = "";
}
}
else if (txtusername.Text == "user")
{
if (com.ExecuteReader().HasRows)
{
Response.Redirect("userinventory.aspx");
Label3.Text = "successfully";
}
else
{
Label3.Text = "not successfully";
txtusername.Text = "";
txtpassword.Text = "";
}
}
con.Close();
}
catch (Exception ex)
{
Console.Write("" + ex.Message);
}
推荐答案
这篇关于想在我的登录页面上定义角色和身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!