Request.ServerVariables("HTTP _... [英] Request.ServerVariables("HTTP_...

查看:62
本文介绍了Request.ServerVariables("HTTP _...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Request.ServerVariables("HTTP_REFERER")

在Internet Explorer中不起作用.

我们有一个要求,例如有两个不同的网站,分别是www.example1.com和www.example2.com.我必须将所有使用www.example1.com的用户重定向到www.example2.com,并且当我们有意在www.example2.com的下拉列表中选择www.example1.com时,它必须打开而不进行任何重定向.

为此,我使用了

is not working in the Internet Explorer.

We have a requirement like, there are two different websites say, www.example1.com and www.example2.com. I have to redirect all the users who uses www.example1.com to www.example2.com, and when we intentionally select www.example1.com in the dropdown list of www.example2.com it should have to open without any redirection.

For this I have used

Request.ServerVariables("HTTP_REFERER") 

在www.example1.com中,以便我可以根据我应用的重定向来识别谁在请求www.example1.com.在所有标准浏览器(例如Mozilla和Google Chrome)中,此方法都非常有效,但不适用于Internet Explorer.

我将以下ASP代码用于www.example1.com

in the www.example1.com so that I can Identify who are requesting www.example1.com based on that I applied redirection. This worked great in All standard browsers like Mozilla and Google Chrome but not applying for Internet Explorer.

I used the below ASP code for www.example1.com

<%if(Request.ServerVariables("HTTP_REFERER") <> "http://www.example2.org/") then

  URL = "http://api.ipinfodb.com/v3/ip-country/?key=c184c2d089c7763a81d7701a662b57fe3bf90dbfd8bf60d29948878531e24472&ip=" &           Request.ServerVariables("REMOTE_ADDR")
                  Set conn = Server.CreateObject("MSXML2.ServerXMLHTTP")
              conn.open "GET", URL, False, "", ""
              conn.send
                  UserCountry = conn.ResponseText
                  conArray = Split(UserCountry, ";")
              if ((conArray(3) = "US")) Then
                  response.redirect("http://www.example2.org/")
              end if
  end if
   %>



它在除IE之外的所有浏览器中都能正常工作.有人知道吗?您是否可以向我建议所有浏览器(包括IE)的等效代码,该代码将给出与上述类似的结果.



It worked fine in all Browsers except IE. Can any one know regarding this? would you please suggest me the equivalent code for ALL BROWSERS (Including IE) which would give similar results as mentioned.

推荐答案

几年前,我遇到了这个问题,但是我设法找到了我创建的网页. (我在网络上的某个地方找到了此替代方法,抱歉不要再抱怨了.).
I had this problem a couple of years ago, but I''ve managed to find the web page I created. (I found this workaround somewhere on the web, sorry don''t remeber).
//bug in explorer forzo la ri-creazione dell'header a mano.
var isOpera, isIE = false;
if(typeof(window.opera) != 'undefined'){isOpera = true;}
if(!isOpera && navigator.userAgent.indexOf('Internet Explorer')){isIE = true;}

function goto(url){
  location.href = url;
}

//ricreo per explorer
if(isIE){
  function goto(url){
    var referLink = document.createElement('a');
    referLink.href = url;
    document.body.appendChild(referLink);
    referLink.click();
  }
}


单击链接时,这会迫使IE重新创建标头,因为有时,由于某些未知原因,资源管理器无法发送标头.您必须将此修复程序放到www.example1.com网站上.
您不能通过查询字符串传递一些加密的变量吗?


This forces IE to recreate the header when clicking on a link as, sometimes, explorer fails to send headers for some unknown reason. You''ll have to put this fix on your www.example1.com website.
Can''t you pass some crypted variabiles by querystring?


这篇关于Request.ServerVariables("HTTP _...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆