忽略主机文件?
我需要从 C# 调用 Response.Redirect 方法,但我需要以这样的方式执行此操作:它会忽略 Windows 上的此调用的 Hosts 文件?
例如,如果在主机上我有:
127.0.0.1 google.com
并且我调用 Response.Redirect("google.com"),我需要它忽略仅针对这一调用的主机,而实际上转到 google.com比本地主机。我怎么能这样做呢?
我知道我可以在谷歌的IP地址上调用Response.Redirect,但是有更好的方法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,可能不会:DNS 查找将移交给您的操作系统,该操作系统会检查...
hosts
文件。如果您可以
那么它可能会工作。
No, probably not: DNS lookup is handed over to your OS, which checks...
hosts
file.Iff you can
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.
如果您无需询问操作系统(例如通过第 3 方)即可知道主机的 IP 地址。那么您实际上忽略了主机文件。
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 .