确定 asp.net ajax 请求来自哪个服务器(在网络场中)?
我在想我们如何找出该页面是从哪台服务器提供的:我会通过在页面上放置一个隐藏变量来实现这一点,该变量具有处理该页面的服务器的 IP 或服务器名称。但是我该如何处理 asp.net ajax 请求:那些作为部分回发发生的请求?我必须将隐藏变量放在更新面板中,但是如果页面中有很多更新面板怎么办?
I was thinking how we can find out which server the page was served from: I'd do so by doing something like put a hidden variable on the page which has the IP or server name from the server it got processed. But what do I do for asp.net ajax requests: those that happen as a partial postback? I'd have to put the hidden variable in the update panel, but what if there are many update panels in the page?
I checked out another SO post, but the solution was for iis 7. What is the equivalent for iis6? And how can we read the header? Where to look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过 IIS MMC 设置 IIS6 自定义标头,方法是打开站点的属性,然后单击“HTTP 标头”选项卡:
您还可以使用
adsutil
(位于c:\InetPub\AdminScripts
中):上面的命令将为默认网站配置 HTTP 标头。
使用
adsutil
时要小心,因为这会覆盖任何已配置的现有标头。要设置多个标头,请执行以下操作:
更新:
关于访问客户端上的响应标头,如果您使用 ASP.NET AJAX 更新面板,请将此脚本添加到页面末尾
:将挂钩到页面请求管理器,这样当 Ajax 请求完成时,您还可以获得底层 XMLHttpRequest 对象的可见性,该对象具有响应标头的副本。
你可以用 jQuery 做类似的事情:
You can set IIS6 custom headers via IIS MMC by opening a site's properties then clicking on the HTTP Headers tab:
You can also use
adsutil
(found inc:\InetPub\AdminScripts
):The command above will configure the HTTP Headers for the default website.
Be careful when using
adsutil
as this will overwrite any existing headers already configured.To set multiple headers do:
Update:
With regard to accessing the response headers on the client, if you're using an ASP.NET AJAX update panel then add this script to the end of your page:
This will hook into the page request manager such that when the Ajax request completes you also get visibility of the underlying XMLHttpRequest object which has a copy of the response headers.
You can do something similar with jQuery: