在 URL 中使用 DNS 时 Web 服务失败,但如果我在 URL 中使用实际 IP 则工作正常无法找出问题
我正在尝试从 ASP.NET 3.5 应用程序调用 Web 服务。我有一个包含 DNS 的 URL,当使用它时,我收到以下错误。
(xxxxxx 是出于隐私考虑) 请求失败,并显示错误消息: -- 301 Moved Permanently
Moved Permanently
该文档已移至此处。
当我将 URL 与物理 IP 一起使用时,它工作得很好。有没有我缺少的设置。我目前将 URL 行为设置为动态,以便它使用 webconfig 中的 url。
I am trying to call a web service from asp.net 3.5 application. I have a URL that has the DNS in it and when it is used I get the following Error.
(the xxxxxx is there for privacy concerns)
The request failed with the error message: -- 301 Moved Permanently
Moved Permanently
The document has moved here.
When I use the URL with the physical IP it works just fine. Are there any setting that I am missing. I currently have the URL behavior set to dynamic so that it uses the url from the webconfig.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯 - 也许我没有正确理解你的问题,但听起来 Web 服务 URL 只是从你使用的 URL 更改为 301 响应返回的 URL(xxxxxxxx 的 URL)。
您确定使用准确 xxxxxxx URL 调用网络服务吗?
附:
这可能不是您想说的 - DNS 代表域名系统,它将是将 URL 转换为 IP 地址的系统。我假设您想说 FQDN,意思是完全合格的域名。
Hm - maybe I do not understand your question correctly, but it sounds like the web service URL simply has changed from the one you use to the one returned by the 301 response (the xxxxxxxx one).
Are you sure you call the web service with exactly the xxxxxxx URL?
PS:
This is probably not what you wanted to say - DNS stands for Domain Name System, which would be the system that translates URLs to IP Addresses. I assume you wanted to say FQDN, meaning Fully Qualified Domain Name.
根据传入的请求(包括您为 URL 中的主机名传递的内容),请求重写可能发生在服务器端。请求重写可能会导致 301 响应。
换句话说,主机名为 www.domain.com 的请求可能会被重写,而使用特定 IP 地址的请求,即使该 IP 地址是 www.domain.com 解析到的地址,也可能不会被重写。
解决方案是使用 IP 地址,或使用从 301 响应中获取的新位置。
It's possible for request rewriting to be happening on the server side, based on the incoming request, including what you pass for the hostname in the URL. A request rewrite may result in a 301 response.
In other words, requests with a hostname of www.domain.com may be rewritten, while requests using a particular ip address, even if the IP address is the address that www.domain.com resolves to, may not be rewritten.
The solution is to either use the IP address, or use the new location that you get from the 301 response.
如果您使用的是 Web 引用,则可以设置
AllowAutoRedirect
属性设置为 true。在这种情况下,重定向将在幕后发生。If you are using a Web Reference, then you can set the
AllowAutoRedirect
property of the proxy instance to true. In this case, the redirection will happen behind the scenes.