asp.net form 验证问题
测试工程:
Login.aspx
Default.aspx
First.aspx
Second.aspx
web.config
Global.asax
代码:
Login.aspx
C# code:
protected void Submit_Click(object sender, EventArgs e)
{
if ((this.UserEmail.Text == "1") && (this.UserPass.Text == "2"))
{
//Create Authentication Ticket
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1,
this.UserEmail.Text.Trim(),
DateTime.Now,
DateTime.Now.AddMinutes(HttpContext.Current.Session.Timeout),
this.Persist.Checked,
this.UserEmail.Text.Trim(), "/");
string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
authCookie.Expires = DateTime.Now.AddMinutes(HttpContext.Current.Session.Timeout);
Response.Cookies.Add(authCookie);
Response.Redirect("Default.aspx");
}
else
this.Msg.Text = "Invalid credentials. Please try again."
相关问答:
select top 12 * from Product where [id] not in (select top 12 [id] from Product)
这样可以分页,但是我在后面想加个条件
select top 12 * from Product where [id] not in (select top 12 [id] from Prod ......
哪位大哥有没有ASP.NET中利用Cookies实现用户自动登录的代码...谢谢了...越详细越好....
什么意思?自动登录?
mark 貌视是存储cookies 我也对cook比较迷糊 关注下
既然你知道用cookies自己动动大脑多好! ......
比较好的学习asp.net的书推荐一下吧,谢谢~~~
書的話等高人推薦, 我認為多上上www.asp.net對你幫助挺大, 那里有很多視頻, 如果是新手的話, 視& ......
ASP.NET 错误 无法识别的标记前缀或设备筛选器“asp”
代码如下:
<%@ Page Language="C#" ContentType="text/xml" AutoEventWireup="true" CodeFile=" ......
如题,我把窗口程序设计成一直在打开网页,然后后台在运行程序,我想问如果用户关闭浏览器,后台能否添加事件处理关闭(主要是释放一些资源)
没有可靠的办法。
浏览器是什么?假设你在浏览器地址栏上打入“ ......