页面A:http://www.a.com/a.html,页面内<script src='http://www.b.com/b.aspx'></script>
页面B:http://www.b.com/b.aspx,在cs里用Request.Url.Host得到的是www.b.com,如何获取到www.a.com的域名或url呢??我的代码是
private string HostName
    {
        get
        {
            string thehost = "";
            thehost= Request.Url.Host;
            if (thehost!= null)
            return thehost;
            return "";
        }
    }
这个得到的是www.b.com而不是www.a.com,尝试了Request.UrlReferrer,得到的是空.NETURL域名HOSTdomain

解决方案 »

  1.   

    补充,只能修改b.aspx和b.aspx.cs,其它无法修改哦
      

  2.   

    如果你是通过script引用的话,那你的
    Request.UrlReferrer就应该是http://www.a.com/a.html
      

  3.   

    a.aspx
    <script src='http://www.b.com/b.aspx?url=<%=  Request.Url.Host %>'></script>
    b.aspxRequest["url"]
      

  4.   

    除了这个办法没有其它了哦,没办法在b.aspx内直接获取了么
      

  5.   

    没错,是这样。
    但是使用过程中,出现大量的出错,什么情况下获取不到UrlReferrer,如果获取不到能获取其他信息吗,比如有的直接静态桌面文件打开一般都是c://dxxxx/xxxx的
      

  6.   

    <script src='http://www.b.com/b.js'></script>http://www.b.com/b.js   ---》
    <script>
    var hj=document.createElement("script");
    hj.setAttribute("charset","utf-8");
    hj.setAttribute("src","b.aspx?from=" + escape(document.location.href));
    document.getElementsByTagName("head")[0].appendChild(hj);
    </script>
      

  7.   


    请把 <script>  和 </script> 去掉