//通過Cookie記錄游客IP5分鐘內,瀏覽次數不會增加
protected void Page_Init(object sender, EventArgs e)
{
//記錄游客的IP及cookie
string userIp =Page.Request.UserHostAddress.ToString();
if (Request.Cookies["userIp"] == null)
{
HttpCookie cookieIp = new HttpCookie("userIp");
DateTime dtNow = DateTime.Now;
TimeSpan tsTime = new TimeSpan(0, 0, 300);//cookie的存活期是60秒
cookieIp.Expires = dtNow + tsTime;
Response.Cookies.Add(cookieIp);
//瀏覽次數+1(更新)
int supplyID = int.Parse(Request.QueryString["SupplyID"].ToString());
string updateHits = "update SupplyInfo set Hits=Hits+1 where SupplyID=" + supplyID;
DataAccess.DC.ExecSqlReturn(updateHits);
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。