asp网页怎么写web访问日志
答案:2 悬赏:20 手机版
解决时间 2021-03-14 20:44
- 提问者网友:回忆在搜索
- 2021-03-14 08:26
asp网页怎么写web访问日志
最佳答案
- 五星知识达人网友:洒脱疯子
- 2021-03-14 08:34
没看懂什么意思?
全部回答
- 1楼网友:归鹤鸣
- 2021-03-14 09:02
''' <summary>
''' 初期化
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
。。。
'写操作log
LogInfo.writeLogInfo(Me)
End Sub
Public Shared Sub writeLogInfo(ByVal myPage As System.Web.UI.Page)
Dim userID As String
Dim userName As String
Dim keyDateTime As String
Dim kb As String
Dim formID As String
Dim formName As String
Dim buttonID As String
Dim buttonName As String
Dim c As WebControls.Button
Dim iIndex As Integer
Try
userID = CType(myPage.Session(ConstantInfo.SESSION_USER_INFO_CONST), UserInfoEntity).UserID
userName = CType(myPage.Session(ConstantInfo.SESSION_USER_INFO_CONST), UserInfoEntity).UserName
keyDateTime = Format(Now, "yyyy-MM-dd HH:mm:ss")
If Not myPage.IsPostBack Then
kb = "1" '画面
iIndex = myPage.AppRelativeVirtualPath.LastIndexOf("/")
If iIndex <> -1 Then
formID = myPage.AppRelativeVirtualPath.Substring(iIndex).Replace("/", "")
Else
formID = myPage.AppRelativeVirtualPath
End If
formName = myPage.Title
buttonID = "-"
buttonName = ""
'插入到LOG表
insertLogTable(userID, userName, keyDateTime, kb, formID, formName, buttonID, buttonName)
Else
kb = "2" '按钮
iIndex = myPage.AppRelativeVirtualPath.LastIndexOf("/")
If iIndex <> -1 Then
formID = myPage.AppRelativeVirtualPath.Substring(iIndex).Replace("/", "")
Else
formID = myPage.AppRelativeVirtualPath
End If
formName = myPage.Title
c = getPostBackControlID(myPage)
If Not c Is Nothing Then
buttonID = c.ID
buttonName = c.Text
'插入到LOG表
insertLogTable(userID, userName, keyDateTime, kb, formID, formName, buttonID, buttonName)
End If
End If
Catch ex As Exception
'do nothing
End Try
End Sub
Private Shared Function getPostBackControlID(ByVal myPage As System.Web.UI.Page) As WebControls.Button
Dim ctrl As Control = Nothing
Dim ctrlName As String = myPage.Request.Params("__EVENTTARGET")
If Not ctrlName Is Nothing AndAlso Not ctrlName.Equals("") Then
ctrl = myPage.FindControl(ctrlName)
Else
Dim ctrlStr As String = ""
Dim c As Control = Nothing
For Each ctl As String In myPage.Request.Form
If ctl.EndsWith(".x") OrElse ctl.EndsWith(".y") Then
ctrlStr = ctl.Substring(0, ctl.Length - 2)
c = myPage.FindControl(ctrlStr)
Else
c = myPage.FindControl(ctl)
End If
If TypeOf (c) Is System.Web.UI.WebControls.Button Then
ctrl = c
Exit For
End If
Next
End If
Return ctrl
End Function
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯