简体   繁体   English

检测浏览器代理设置已启用还是未使用Javascript

[英]Detect browser proxy setting enabled or not using Javascript

We have a coupon download functionality in our website. 我们的网站上有优惠券下载功能。 Users should download a plugin which allows them to then download the actual coupon. 用户应该下载一个插件,该插件可以让他们下载实际的优惠券。 Plugin download is not working in IE6 with proxy settings. 使用代理设置的IE6中插件下载不起作用。 It is working in all other browsers even with proxy setting. 即使使用代理设置,它也可以在所有其他浏览器中使用。 Now, my client want to display some message to the user if the user is using IE6 with proxy. 现在,如果用户将IE6与代理一起使用,我的客户端希望向用户显示一些消息。 Ex: Alert message like "You are using IE6 with proxy. Please try in some other browser". 例如:警报消息,例如“您正在将IE6与代理一起使用。请在其他浏览器中尝试”。

Now, question is - How to detect whether the browser is using proxy or not using Javascript? 现在,问题是-如何检测浏览器是否使用代理? Thanks in advance for any help. 在此先感谢您的帮助。

You can't do that with javascript. 您无法使用javascript做到这一点。 I think the best option is, what Zed has said, solve it at serve side using HTTP-HEADERS. 我认为最好的选择是Zed所说的,使用HTTP-HEADERS在服务端解决它。

In ASP.NET you can do something like that: ASP.NET中,您可以执行以下操作:

bool IsUsingProxy = Request.Headers
            .AllKeys
            .Any(header => header.Equals("HTTP_X_FORWARDED_FOR", 
                            StringComparison.CurrentCultureIgnoreCase));

The only down sidee is that it will only work with users using transparent proxies. 唯一的缺点是,它将仅与使用透明代理的用户一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM