How do I get root url using ASP not ASP.net? I have found this question ( How do I get the site root URL? )
but it is related to ASP.net.
=====================================
Abbas's answer provide me the
parent site root url
but does not provide me the subsite root url
=====================================
You can determine your server's root URL by browsing to a page on your website and observing the address in the location/address entry field of the browser. The root URL is the section between the colon-slash-slash (://) and the next slash (/), omitting any port number (:portno).
How to Get the Base URL in an MVC Controller. Here's a simple one-liner to get the job done. var baseUrl = string. Format(“{0}://{1}{2}”, Request.
It represents an available URL namespace (for example, http://example). The Web application root is the folder on your hard disk that corresponds to this URL namespace. For example, placing a file called file. htm in the Web application root folder results in an available URL at http://example/file.htm.
A URL (Uniform Resource Locator) or webpage address, is a reference to a web resource that specifies its exact location online (within a computer network). A content URL refers to a webpage address that specifically relates to certain content on the internet, such as an image or a video file.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With