在开发及实际中 会是这样,登录后自动返回请求的URL
由于所有页面都继承父页面,可以在父页面中得到url,登录以后转向原请求页面。
登录按钮事件也做相应调整
登录按钮事件
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--> private void btnSub_Click(object sender, System.EventArgs e)
{
if(txtUserPwd.Text==""||txtUserName.Text=="")
{
Utils.MessageBox("用户名或密码不能为空!");
return;
}
string name = txtUserName.Text.Trim().Replace("'","");
string pwd = txtUserPwd.Text.Trim().Replace("'","");
string uid = ValidateLogin(name,pwd);
if(int.Parse(uid)>0)
{
//entity.User u = new User(uid);
HttpCookie cookie = new HttpCookie("userId",uid);//由于cookie只能保持string类型,uid也改成string类型
Response.Cookies.Add(cookie);
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-544946/,如需转载,请注明出处,否则将追究法律责任。