开发者

Get Client Machine ID

开发者 https://www.devze.com 2023-03-10 17:22 出处:网络
I need to get Client\'s Machine ID and their Country in my web application... Is it possible开发者_JAVA百科 get succeed in this?

I need to get Client's Machine ID and their Country in my web application...

Is it possible开发者_JAVA百科 get succeed in this?


using System.Globalization;

string culture = CultureInfo.CurrentCulture.EnglishName;
string country = culture.Substring(culture.IndexOf('(')

+ 1, culture.LastIndexOf(')') - culture.IndexOf('(')-

Client Country in C#


Get Client Computer Name, How to get the client machine name from a server

You will get most of the details of the client machine using the "Request.ServerVariables"

// Try the following C# code 
System.Net.IPHostEntry host = new System.Net.IPHostEntry(); 
host = System.Net.Dns.GetHostByAddress(Request.ServerVariables["REMOTE_HOST"]);

lbl.Text = host.HostName;


Host name:

Request.ServerVariables["REMOTE_HOST"] 

See http://www.w3schools.com/asp/coll_servervariables.asp

Resolve country:

public static RegionInfo ResolveCountry()
{
  CultureInfo culture = ResolveCulture();
  if (culture != null)
    return new RegionInfo(culture.LCID);

  return null;
}

from http://madskristensen.net/post/Get-language-and-country-from-a-browser-in-ASPNET.aspx

This uses the PC's setup Language/Country.

By IP try an example at:

http://dotnetguts.blogspot.com/2008/06/finding-country-from-visitors-ip-in.html

Which involves checking the requesting IP adresses against a database of IP locations.

You could also use an IP for a service that already supports this such as:

http://www.ipgeo.com/api/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号