无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
/// <summary>
/// 获取用户操作系统信息
/// </summary>
/// <returns></returns>
public string GetUserOS()
{
string strSysVersion = "其他";
HttpRequest Request = HttpContext.Current.Request;
string strAgentInfo = Request.ServerVariables["HTTP_USER_AGENT"];
if (strAgentInfo.Contains("NT 6.0"))
{
strSysVersion = "Windows Vista";
}
else if (strAgentInfo.Contains("NT 5.2"))
{
strSysVersion = "Windows 2003";
}
else if (strAgentInfo.Contains("NT 5.1"))
{
strSysVersion = "Windows XP";
}
else if (strAgentInfo.Contains("NT 5"))
{
strSysVersion = "Windows 2000";
}
else if (strAgentInfo.Contains("NT 4.9"))
{
strSysVersion = "Windows ME";
}
else if (strAgentInfo.Contains("NT 4"))
{
strSysVersion = "Windows NT4";
}
else if (strAgentInfo.Contains("NT 98"))
{
strSysVersion = "Windows 98";
}
else if (strAgentInfo.Contains("NT 95"))
{
strSysVersion = "Windows 95";
}
else if (strSysVersion.ToLower().Contains("Mac"))
{
strSysVersion = "Mac";
}
else if (strSysVersion.ToLower().Contains("unix"))
{
strSysVersion = "UNIX";
}
else if (strSysVersion.ToLower().Contains("linux"))
{
strSysVersion = "Linux";
}
else if (strSysVersion.Contains("SunOS"))
{
strSysVersion = "SunOS";
}
return strSysVersion;
}
/// <summary>
/// 获取客户端浏览器类型及版本
/// </summary>
/// <returns></returns>
public string GetUserBrowser()
{
string strBrowser = "其他";
HttpRequest Request = HttpContext.Current.Request;
string strAgentInfo = Request.ServerVariables["HTTP_USER_AGENT"];
if (Regex.IsMatch(strAgentInfo, "MSIE ([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "MSIE ([//d]//.[//d])").Result("IE:$1");
}
else if (Regex.IsMatch(strAgentInfo, "Opera ([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "Opera ([//d]//.[//d])").Result("Opera:$1");
}
else if (Regex.IsMatch(strAgentInfo, "Opera///([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "Opera///([//d]//.[//d])").Result("Opera:$1");
}
else if (Regex.IsMatch(strAgentInfo, "Firefox///([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "Firefox///([//d]//.[//d])").Result("Firefox:$1");
}
return strBrowser;
}
#region GetIP()
/// <summary>
/// 获取IP
/// </summary>
/// <returns></returns>
public string GetIP()
{
string uip = "";
if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
uip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
uip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
return uip;
}
#endregion
/// <summary>
/// 获取用户操作系统信息
/// </summary>
/// <returns></returns>
public string GetUserOS()
{
string strSysVersion = "其他";
HttpRequest Request = HttpContext.Current.Request;
string strAgentInfo = Request.ServerVariables["HTTP_USER_AGENT"];
if (strAgentInfo.Contains("NT 6.0"))
{
strSysVersion = "Windows Vista";
}
else if (strAgentInfo.Contains("NT 5.2"))
{
strSysVersion = "Windows 2003";
}
else if (strAgentInfo.Contains("NT 5.1"))
{
strSysVersion = "Windows XP";
}
else if (strAgentInfo.Contains("NT 5"))
{
strSysVersion = "Windows 2000";
}
else if (strAgentInfo.Contains("NT 4.9"))
{
strSysVersion = "Windows ME";
}
else if (strAgentInfo.Contains("NT 4"))
{
strSysVersion = "Windows NT4";
}
else if (strAgentInfo.Contains("NT 98"))
{
strSysVersion = "Windows 98";
}
else if (strAgentInfo.Contains("NT 95"))
{
strSysVersion = "Windows 95";
}
else if (strSysVersion.ToLower().Contains("Mac"))
{
strSysVersion = "Mac";
}
else if (strSysVersion.ToLower().Contains("unix"))
{
strSysVersion = "UNIX";
}
else if (strSysVersion.ToLower().Contains("linux"))
{
strSysVersion = "Linux";
}
else if (strSysVersion.Contains("SunOS"))
{
strSysVersion = "SunOS";
}
return strSysVersion;
}
/// <summary>
/// 获取客户端浏览器类型及版本
/// </summary>
/// <returns></returns>
public string GetUserBrowser()
{
string strBrowser = "其他";
HttpRequest Request = HttpContext.Current.Request;
string strAgentInfo = Request.ServerVariables["HTTP_USER_AGENT"];
if (Regex.IsMatch(strAgentInfo, "MSIE ([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "MSIE ([//d]//.[//d])").Result("IE:$1");
}
else if (Regex.IsMatch(strAgentInfo, "Opera ([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "Opera ([//d]//.[//d])").Result("Opera:$1");
}
else if (Regex.IsMatch(strAgentInfo, "Opera///([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "Opera///([//d]//.[//d])").Result("Opera:$1");
}
else if (Regex.IsMatch(strAgentInfo, "Firefox///([//d]//.[//d])", RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
strBrowser = Regex.Match(strAgentInfo, "Firefox///([//d]//.[//d])").Result("Firefox:$1");
}
return strBrowser;
}
#region GetIP()
/// <summary>
/// 获取IP
/// </summary>
/// <returns></returns>
public string GetIP()
{
string uip = "";
if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
uip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
uip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
return uip;
}
#endregion
标签:
ASP.net,获取客户端参数
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月20日
2024年11月20日
- 罗大佑-无法盗版的青春套装版10CD【WAV】
- 张学友《意乱情迷》蜚声环球 2024 [WAV+CUE][1G]
- 柏菲《好歌30年特别版2CD》最好听的影视歌曲[低速原抓WAV+CUE][1G]
- 张学友《世纪10星·永恒篇》香港版[WAV+CUE][1G]
- 模拟之声慢刻CD《刘德海.琵琶独奏精逊【低速原抓WAV+CUE】
- Jamettone-18052023—improv(EDit)(2024)【FLAC】
- 【索尼精芽20首最棒的苏格兰歌曲集【FLAC】
- 池约翰C.J《少年白马醉春风2 动画原声带》[320K/MP3][26.67MB]
- 池约翰C.J《少年白马醉春风2 动画原声带》[FLAC/分轨][144.13MB]
- 陈致逸《幻想乐园 Fantasyland》[320K/MP3][120.54MB]
- 席卷全球最红舞曲《火辣辣DJ[英文版]》[DTS-WAV]
- 群星-席卷全球最红舞曲《火辣辣DJ中文版》【WAV】
- 模拟之声慢刻CD《声入人心[年度发烧人声严选]》[低速原抓WAV+CUE]
- 陈致逸《幻想乐园 Fantasyland》[FLAC/分轨][554.27MB]
- Rhymist / LusciousBB《年轮》[320K/MP3][76.52MB]