1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System.Net.Dns.GetHostName()
根据电脑名取出全部IP地址:static System.Net.Dns.Resolve(电脑名
).AddressList
也可根据IP地址取出电脑名:static System.Net.Dns.Resolve(IP地址
).HostName
3. 系统环境类的通用属性:
当前电脑名:static System.Environment.MachineName
当前电脑所属网域:static System.Environment.UserDomainName
当前电脑用户:static System.Environment.UserName
4 利用System.Security.Princip al;
if(User.Identity.IsAuthenticated)
{ WindowsIdentity CurrentIdentity = WindowsIdentity.GetCurrent();
message.Text="用戶的windows登陸名稱:<b>"+CurrentIdentity.Name+"<br><br>";
Response.Write(str.Substring(0,4));
}
本文详细介绍了在ASP.NET中获取服务器、客户端信息的专用属性,以及在网络编程中获取当前电脑名、所有IP地址的方法。同时,通过System.Security.Principals类实现了验证用户身份并获取其登录名。

5075

被折叠的 条评论
为什么被折叠?



