'ASP.NET cannot resolve user hostname in azure

I have written an ASP.net website that gets the machine name from the person browsing the website using

sName = System.Net.Dns.GetHostEntry(Request.UserHostAddress).HostName.ToString

If I publish this to a web server on our local network, it works fine.

We also have an Azure server and I want to publish it to that server, but it does not return the machine name. We have the Azure server connected to our local network via a permanent tunnel.

I'm assuming that the code can't resolve the name as it can access the DNS on the network. Is there a way around this?

Thanks

Gareth



Solution 1:[1]

AFAIK, Our app will not work with Azure DNS Private Zones automatically. To work with Azure DNS Private Zones we need to add the below in app settings:

WEBSITE_DNS_SERVER with value 168.63.129.16

WEBSITE_VNET_ROUTE_ALL with value 1

For more information please refer this MS Q&A as suggested by @ didier3001

And this for use Dns.GetHostEntry Method

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AjayKumarGhose-MT