string PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName; this is working for my laptop or pc same way i want even for mobile device
Loading
string PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName; this is working for my laptop or pc same way i want even for mobile device
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Naimish MakwanaPosted Apr 5, 2024, 7:09 AM
The code you’ve provided is used to get the hostname of a device based on its IP address. This works for any device that has an IP address and a hostname, including mobile devices. However, there are a few things to keep in mind:
Privacy and Permissions: Mobile operating systems have strict privacy controls and may not allow you to access this information.
Network Address Translation (NAT): If the device is behind a router or a mobile network, the IP address you’re getting is likely the public IP address of the router or the mobile network gateway, not the device itself.
Dynamic IP: IP addresses for mobile devices can change frequently. This is especially true for devices on mobile networks.
Hostname Resolution: The ability to resolve an IP address to a hostname depends on the reverse DNS setup of the network provider, which you don’t control.
Because of these reasons, this method may not always return the expected result for mobile devices. If you’re trying to identify devices connecting to your server, consider using a method that doesn’t rely on IP addresses and hostnames, such as using unique device identifiers or user logins.
Thanks