在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
对于一次服务器端的控件事件,都有***的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
【编辑推荐】
- P.NET DetailsView中显示选中产品的详细信息
- P.NET 2.0数据教程:GridView选择行
- ASP.NET 2.0数据教程:GridView显示数据
- ASP.NET 2.0中添加GridView到页面
- 新增ASP.NET页面时的注意事项