vs2010实际项目ASP.NET小试练完整页
下面就该实现website里面的登录模块了。
这里使用Cookie来存储用户信息,
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// UserCookies 的摘要说明
/// </summary>
public class UserCookies
{
public const string cksUserName = "COOKIES_1_1";
public UserCookies()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void SetCookies(string name, string Value)
{
System.Web.HttpContext.Current.Response.Cookies.Add(new System.Web.HttpCookie(name, Value));
}
public void SetCookies(Model.Login user)
{
SetCookies(cksUserName, user.username);
}
public string GetCookies(string name)
{
if (System.Web.HttpContext.Current.Request.Cookies[name] == null)
return "";
if (System.Web.HttpContext.Current.Request.Cookies[name].Value == null || System.Web.HttpContext.Current.Request.Cookies[name].Value == "")
return "";
return System.Web.HttpContext.Current.Request.Cookies[name].Value;
}
public void ClearUserCookies()
{
SetCookies(cksUserName, "");
}
}
附件下载:http://down.9upk.com/soft1/leiku.zip
本文导航
- 第1页: 首页
- 第2页: 登录模块
- 第3页: 实现website里面的登录模块