I have application want to get user machine name, here I can retrieve and it works fine in localhost.
string clientPCName;
string[] computer_name = System.N
Machine names are a concept for local networks only, and local AD networks/forests at that. Once you expose your site on the internet machine names no longer make sense, instead you get DNS names.
So, for example, on my the work network my laptop name resolves to bdorrans01.redmond.contoso.com. But if I browse to a web site from home my current ip address resolves to c-98-203-143-14.hsd1.wa.comcast.net.
You are taking the FQDN and dropping everything after the first period/full stop. That works in an AD environment (sort of), and your code would see bdorrans01 internally, but it would see c-98-203-143-14 externally.
Even internally within a multi-forest AD it would also be wrong if your web site was hosted in another forest, for example if you site lived on example.europe.contoso.com, your code would get a machine name of bdorrans01, but my machine wouldn't be in the same forest, and if you tried to ping it, or map to a network drive it wouldn't be found, because you would be looking for bdorrans01 in europe.contoso.com, not redmond.contoso.com where it actually is.
Also your code assumes that resolving an IP address will produce a fully qualified domain name, this isn't true in a lot of cases, you could just get an IP address back, so you may see 1.2.3.4 and your code would give a machine name of 1. Worse yet it'll not do anything to an IPv6 address as they use colons to separate, 2001:db8:85a3:8d3:1319:8a2e:370:7348
So your premise is incorrect - and you need to find a different way to do what you're trying to do. Why do you believe you need the machine name anyway?