为什么 Cassini Web 服务器将我的完全限定域名请求 URL 转换为 IP 地址请求 URL?
我有一个网络应用程序,它依赖于浏览器客户端保留 FQDN 才能正常工作,但发生的情况是,在多个浏览器中,我看到 url 被转换为 IP 地址 url(包含正确的 IP 地址),该地址通过来自 Web 服务器的重定向而发生变化。
托管资源的 Web 服务器是 Cassini,HttpRequest 类 Url 属性 返回 URL 中的 IP 地址,而不是 FQDN。
关于如何改变这种行为有什么建议吗?
I have a web application which depends on the browser client retaining the FQDN in order for it to work, but what is happening is that in multiple browsers I am seeing the url get converted into an ip address url (containing the correct IP address) which is getting changed by a redirect from the web server.
The web server hosting the resource is Cassini, and the HttpRequest class Url property is returning the IP address in the URL instead of the FQDN.
Any suggestions on how to change this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能是您的网络服务器配置错误。 例如,在 apache 中,可以使用
ServerName
指令设置在执行某些重写过程时要使用的规范主机名。 一种常见的情况是 Web 服务器在 URL 末尾添加斜杠(“http://example.com/path< /a>" → "http://192.168.1.1/path/")。我建议看一下curl 的情况。
This is probably a misconfiguration in your web server. In apache (for example), one can set the canonical host name to be used when doing certain rewrite procedures using the
ServerName
directive. One common one is when the web server adds slash to the end of your URL ("http://example.com/path" → "http://192.168.1.1/path/").I recommend taking a peek at what's going on with curl.
这不是 DNS 问题,而是 Web 服务器配置问题。
是的,DNS 用于将 URL 的主机名部分转换为 IP 地址。
但是,该 IP 地址永远不会出现在浏览器栏中,除非 Web 服务器通过发送重定向来告诉它。
This is not a DNS issue, it's a web server configuration issue.
Yes, the DNS is used to convert the hostname part of the URL into an IP address.
However that IP address will never appear in the browser bar unless the web server tells it to by sending a redirect.
感谢所提供的有用信息,我能够将此问题追溯到 HttpWorkerRequest .NET Framework 的抽象类,作为 Cassini 实现的一部分。 Cassini 实现无法覆盖 GetServerName,并且基本实现返回的是 IP 地址而不是域名。
Thanks to the helpful information provided, I was able to track down this issue to an incomplete implementation of the HttpWorkerRequest abstract class of the .NET Framework as part of the Cassini implementation. The Cassini implementation failed to override the GetServerName and the base implementation was returning the IP address instead of the domain name.