在asp.net web应用程序中如果我们想表示用户操作信息,就必须有一些***性标识,下面接口分五层描述用户操作信息:
1.用户名:直接标识操作者用户名
2.用户IP地址:通过IP地址标识操作进行时操作者所在物理机器
3.用户SessionId:用来标识用户浏览器所使用的会话信息,具有线程***性
4.用户操作画面ID:标识用户在所操作的页面
5.用户操作事件ID:标识用户进行操作的事件(服务器端控件ID)
ASP.NET Web应用程序范例代码:
Public Interface IOperatable
Property UserName() As String
Property IPAddress() As String
Property SessionId() As String
Property ScreenId() As String
Property EventId() As String
End Interface
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
对于一次服务器端的控件事件,都有***的HTTP请求被发送的服务器端,同时开启***线程来处理此请求。即对于用户操作信息应该具有线程***性,所以定义线程静态变量Current来保存当前线程的用户操作信息,这样在一次赋值后即可通过“OperationInfo.Current”的形式来获得用户操作信息,而无需在各层次的方法间传递用户操作信息。
ASP.NET Web应用程序范例代码:
Imports RichardTsuei.Core
Public Class OperationInfo
Implements IOperatable
< ThreadStatic()> _
Private Shared _Current As IOperatable
Public Property Current() As IOperatable
Get
Return _Current
End Get
Set(ByVal value As IOperatable)
_Current = value
End Set
End Property
Private _UserName As String
Public Property UserName() As String Implements Core.IOperatable.UserName
Get
Return _UserName
End Get
Set(ByVal value As String)
_UserName = value
End Set
End Property
Private _IPAddress As String
Public Property IPAddress() As String Implements Core.IOperatable.IPAddress
Get
Return _IPAddress
End Get
Set(ByVal value As String)
_IPAddress = value
End Set
End Property
Private _SessionId As String
Public Property SessionId() As String Implements Core.IOperatable.SessionId
Get
Return _SessionId
End Get
Set(ByVal value As String)
_SessionId = value
End Set
End Property
Private _ScreenId As String
Public Property ScreenId() As String Implements Core.IOperatable.ScreenId
Get
Return _ScreenId
End Get
Set(ByVal value As String)
_ScreenId = value
End Set
End Property
Private _EventId As String
Public Property EventId() As String Implements Core.IOperatable.EventId
Get
Return _EventId
End Get
Set(ByVal value As String)
_EventId = value
End Set
End Property
End Class
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
【编辑推荐】
- P.NET DetailsView中显示选中产品的详细信息
- P.NET 2.0数据教程:GridView选择行
- ASP.NET 2.0数据教程:GridView显示数据
- ASP.NET 2.0中添加GridView到页面
- 新增ASP.NET页面时的注意事项