如何在Classic ASP中获取当前域?

And*_*son 14 asp-classic

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

Ede*_*com 27

Request.ServerVariables("SERVER_NAME")'
Run Code Online (Sandbox Code Playgroud)

要完成,我的一个职能:

  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
Run Code Online (Sandbox Code Playgroud)