代码之家  ›  专栏  ›  技术社区  ›  Andrew G. Johnson

如何获取经典ASP中的当前域?

  •  14
  • Andrew G. Johnson  · 技术社区  · 15 年前

    我要获取当前域,因此如果页面是 http://www.domain.com/page.asp 我需要 www.domain.com

    4 回复  |  直到 8 年前
        1
  •  27
  •   Edelcom    15 年前
    Request.ServerVariables("SERVER_NAME")'
    

    要完成,我的一个功能是:

      function PageUrl
         dim sPort
         sPort = Request.ServerVariables("SERVER_PORT")
         if sPort = "80" then
            sPort = ""
         else
            sPort = ":" & sPort
         end if
    
         PageUrl = "http://" & Request.ServerVariables("SERVER_NAME") & sPort & _
                               Request.ServerVariables("URL") & "?" & _
                               Request.ServerVariables("QUERY_STRING")
      end function
    
        2
  •  1
  •   bryanjonker    15 年前

    请求服务器变量之一(服务器名?)

    http://www.w3schools.com/asp/coll_servervariables.asp

        3
  •  0
  •   Tim Cooper    13 年前

    把这个放在函数结束之前删除 ? 当没有querystring元素时,作为随机的 ? 最后可能不是你想要的:

    If right(PageUrl,1)="?" then PageUrl = left(PageUrl,len(PageUrl)-1)
    
        4
  •  0
  •   MRRaja    8 年前
    <%
    for each x in Request.ServerVariables
    response.write(x&"="&Request.ServerVariables(x)&"<br>")
    next
    %>
    

    这将为您提供与所有request.servervariables类似的结果。

    REMOTE_ADDR = 40.20.170.160
    REMOTE_HOST = 40.20.170.160
    REMOTE_USER = 
    REQUEST_METHOD = GET
    SCRIPT_NAME = /xyz/get.asp
    SERVER_NAME = www.xyz.com
    SERVER_PORT = 80