开发者

Ignore hosts file?

I need to call a Response.Redirect method from C# but I need to do it in such a way that it ignores the Hosts file on windows for this call?

For example, if on Hosts I have:

127.0.0.1 google.com

and I call a Response.Redirect("google.com"), I need it to ignore the hosts just for this one call and actually go to google.开发者_如何学运维com rather than localhost. How could I do this?

I know I could call a Response.Redirect on google's IP address but is there a better way?


No, probably not: DNS lookup is handed over to your OS, which checks...hosts file.

Iff you can

  • look up the IP address without the OS's resolver
  • and the target server accepts IP address instead of hostname (some webservers will refuse to serve http://10.15.6.4/some/path (Google Search accepts an IP hostname and works, btw)),

then it might work.


The only way to ignore the hosts file is to delete it.


If you can know the IP address of the host without asking the OS ( e.g. via 3rd party ) .. then you actually ignored the hosts files .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜