我如何使用ASP不是ASP.net获得root网址 [英] How do I get root url using ASP not ASP.net
本文介绍了我如何使用ASP不是ASP.net获得root网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要如何使用ASP不是ASP.net根网址是什么?
我发现这个问题(
如何获取站点根URL?
)
How do I get root url using ASP not ASP.net? I have found this question ( How do I get the site root URL? )
但它关系到ASP.net。
but it is related to ASP.net.
=====================================
=====================================
阿巴斯的回答我提供
父站点根URL
但不提供我的子网站根URL
but does not provide me the subsite root url
=====================================
=====================================
推荐答案
经典的ASP有一个Request.ServerVariables集合包含所有服务器和环境的详细信息。下面是这个例子.NET code的传统的ASP版本是这样的:
Classic ASP had a Request.ServerVariables collection that contained all server and environment details. Here's what the classic ASP version of the example .NET code looks like:
function getSiteRootUrl()
dim siteRootUrl, protocol, hostname, port
if Request.ServerVariables("HTTPS") = "off" then
protocol = "http"
else
protocol = "https"
end if
siteRootUrl = protocol & "://"
hostname = Request.ServerVariables("HTTP_HOST")
siteRootUrl = siteRootUrl & hostname
port = Request.ServerVariables("SERVER_PORT")
if port <> 80 and port <> 443 then
siteRootUrl = siteRootUrl & ":" & port
end if
getSiteRootUrl = siteRootUrl
end function
这篇关于我如何使用ASP不是ASP.net获得root网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文