加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

记录用户访问页面的记录。

发布时间:2020-12-17 01:25:33 所属栏目:安全 来源:网络整理
导读:注意一定要加 context.BeginRequest += new EventHandler(context_BeginRequest); 因为它的 init 事件只会执行一次。而 BeginRequest? 事件则每次请求都会执行。 ? ? using System; using System.Collections.Generic; using System.Linq; using System.Web;

注意一定要加

context.BeginRequest += new EventHandler(context_BeginRequest);

因为它的 init 事件只会执行一次。而 BeginRequest? 事件则每次请求都会执行。

?

?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

??? /// <summary>
??? /// $codebehindclassname$ 的摘要说明
??? /// </summary>
??? [WebService(Namespace = "http://tempuri.org/")]
??? [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
??? public class RecordHandler : IHttpModule
??? {

??????? private void InsertRecord(HttpApplication context)
??????? {
??????????? string connString = System.Configuration.ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
??????????? DataAccess.SqlProvider db = new DataAccess.SqlProvider(connString);
??????????? string pageName = context.Context.Request.FilePath;

??????????? string sqlText = string.Format("insert into tbpageRecord(page) values('{0}')",pageName);
??????????? db.ExecuteSQL(sqlText);
??????????? db.disCounect();
??????? }

??????? #region IHttpModule 成员

??????? void IHttpModule.Dispose()
??????? {
??????????? throw new NotImplementedException();
??????? }

??????? void IHttpModule.Init(HttpApplication context)
??????? {
??????????? context.BeginRequest += new EventHandler(context_BeginRequest);
???????????
??????? }

??????? void context_BeginRequest(object sender,EventArgs e)
??????? {
??????????? HttpApplication context = (HttpApplication)sender;
??????????? InsertRecord(context);
??????? }

??????? #endregion

???? }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读