0

I don't think this is duplicate of System.Net.WebRequest not respecting hosts file since I do not believe my issues to be proxy related (and it's making the request to localhost essentially).

So I've got a C# ASP page that makes an HttpWebRequest. Now, on this server I've done some custom mapping of some dev domains to the server's IP address.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create( "http://someproject.dev" );

ERROR: 
The remote name could not be resolved: 'someproject.dev' at System.Net.HttpWebRequest.GetResponse()

My Hosts file on the server (and my client) has 10.0.1.115 someproject.dev I've also tried it with 127.0.0.1 on the server

Another note, both .net apps are running under hosts file/IIS mappings, i.e. one app is making a x-domain request to the other (which is permitted, i know that's not the cause because this works in our production environment).

Also, I'd like to avoid System.Net.Dns, unless you guys agree that's the only way it will work.

Community
  • 1
  • 1
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
  • 1
    Have you verified that when you use `ping someproject.dev` on the server running the ASP Page that it resolves? –  May 04 '12 at 01:16
  • What happens when you try to browse to `http://someproject.dev` from a browser on the server? – Tung May 04 '12 at 01:54
  • ah ok, thanks. made me realize that the system was not recognizing it.. – FlavorScape May 04 '12 at 17:10
  • BTW just as a tip to future readers, chrome apparently will let *.localhost even if it isn't in the hosts file work, but IE and HttpWebRequest require it in the hosts file. So just because it works in chrome doesn't mean it will work in IE and HttpWebRequest – mirhagk Dec 29 '16 at 19:04

1 Answers1

0

I would check your server. Any web calls that are made from the server are checked to see if the DNS is in the hosts file. Sounds like a server problem instead of a programming problem.

Gabriel Graves
  • 1,751
  • 1
  • 22
  • 40
  • 1
    Not very helpful, but you're right. Turns out there were several OS installed on this machine and I was editing the wrong hosts file. feel like an idiot now. – FlavorScape May 04 '12 at 17:10