请在IIS下加一个虚拟目录,名为QuickStart,映射到你的visual studio目录中的:
D:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\QuickStart打开浏览器 http://localhost/quickstart
慢慢看吧,想要的问题都有了
D:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\QuickStart打开浏览器 http://localhost/quickstart
慢慢看吧,想要的问题都有了
+ 根据用户名读取数据库
+用户名不存在——返回用户名不存在的提示
+用户名存在
+验证密码是否相符
+密码相符合
| FormsAuthentication.RedirectFromLoginPage(name.Text,false);
| Response.Redirect("admin_main_page.aspx",true);
+密码不符合——返回密码错误的提示web.config里面一段配置文件示例。如需保护admin_main_page.aspx页面,那么:
<configuration>
<location path="admin_main_page.aspx">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>
</configuration>
在login.aspx中:
private void UserLogin(object sender, System.EventArgs e)
{
SqlCommand sqlCmd=new SqlCommand("select uid,upwd from users where uid='"+
textbox1.text+" and upwd='"+
textbox2.text+"'",sqlConn);
SqlDataReader sqlRead;
sqlConn.Open();
sqlRead=sqlCmd.ExecuteReader();
if(sqlRead.Read()) Session["uID"]=sqlRead.Getstring;
}
在其他所有需要先登录才能使用的页面中
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["uID"]==null)
{
Response.Redirect("login.aspx");
return;
}
}
建议不要使用各种配置文件来管理