When I call Dns.GetHostEntry(“SomeServerName”) from a console application on my desktop it resolves the IP address just fine. When I execute the same code in an ASP.NET application, also running on my desktop, I get a SocketException with the message “Unknown host”.
I sense that there may be wrong with my IIS / ASP.NET installation, but I don’t have the time right now to try reinstalling.
As a test, I changed the identity of the ASP.NET account in the machine.config to use my own network credentials, but that didn’t make any difference.
Any ideas?
Update:
It seems I need to clarify. I’m having problems doing network communication from ASP.NET on my workstation. This includes trying to send emails using the SmtpClient and also trying to connect to a IBM DB2 via an ODBC connection. These things all work fine when running in a console application. The root cause seems to be that when the code is running under ASP.NET, DNS resolution fails, although I have no idea why. The only difference I can think of is the security context.
Update 2:
Here are some results from running Wireshark:
When the call is made from a console application, I immediately see 2 “Standard Domain Name System Queries” being sent across the network.
When the same call is made from an ASP.NET application, after a delay of about 8 seconds, I see 3 “NetBIOS Name Service Queries” being sent across the network.
Any ideas?
Problem solved : The antivirus program on my workstation was explicitly blocking outgoing connections from IIS, ostensibly to stop worms from spreading around the network.