Summary of URL functions obtained by ASP

Source: Internet
Author: User
Tags servervariables

Method 1: simple. There is no parameter, and there is only one virtual path. CopyCode The Code is as follows: geturl = request ("url ")

Example: http: // 127.0.0.1/Shiyan. asp? Dfsdfsf = dsfsdfd & aa = dddd
Obtain Shiyan. aspCopy codeThe Code is as follows: <%
Dim Changdu, URL, ends, Wurl
Changdu = Len (request. servervariables ("url "))
Url = 2.16rev (request. servervariables ("url "),"/")
Url = URL + 1
Ends = Changdu + 1-url
Wurl = mid (request. servervariables ("url"), URL, ends)
%>

Method 2: Obtain the entire URL and obtain the parameters. Copy codeThe Code is as follows: 'get the address of the current page
Function geturl ()
On Error resume next
Dim strtemp
If lcase (request. servervariables ("HTTPS") = "off" then
Strtemp = "http ://"
Else
Strtemp = "https ://"
End if
Strtemp = strtemp & request. servervariables ("SERVER_NAME ")
If request. servervariables ("server_port") <> 80 then strtemp = strtemp & ":" & request. servervariables ("server_port ")
Strtemp = strtemp & request. servervariables ("url ")
If trim (request. querystring) <> "then strtemp = strtemp &"? "& Trim (request. querystring)
Geturl = strtemp
End Function

Example: http: // 127.0.0.1/Shiyan. asp? Dfsdfsf = dsfsdfd & aa = dddd
Get http: // 127.0.0.1/Shiyan. asp? Dfsdfsf = dsfsdfd & aa = dddd

method 3: Obtain the virtual path. Obtain the parameter copy Code the code is as follows: Private function geturl ()
dim scriptaddress, m_itemurl, m_item
scriptaddress = CSTR (request. servervariables ("script_name") 'gets the current address
m_itemurl = ""
If (request. querystring <> "") Then
scriptaddress = scriptaddress &"? "
for each m_item in request. querystring
If m_item = "page_num" then exit for 'the function here is to filter out the page_num page parameters (this parameter is set in page_turn.asp, changes based on personal settings). Otherwise, this parameter will be added every time you flip the page. Although this parameter does not affect the function, it is always not good ~~
If instr (page, m_item) = 0 then
m_itemurl = m_itemurl & m_item & "=" & server. urlencode (request. querystring ("& m_item &")
else
m_itemurl = m_itemurl & m_item & "=" & server. urlencode (request. querystring ("& m_item &") & "&"
end if
next
else
scriptaddress = scriptaddress &"? "
end if
geturl = scriptaddress & m_itemurl
end function

Example: http: // 127.0.0.1/Shiyan. asp? Dfsdfsf = dsfsdfd & aa = dddd
Get:/Shiyan. asp? Dfsdfsf = dsfsdfd & aa = dddd

Method 4: obtain only some parameters Copy codeThe Code is as follows: function geturl ()
On Error resume next
Dim strtemp
If lcase (request. servervariables ("HTTPS") = "off" then
Strtemp = "http ://"
Else
Strtemp = "https ://"
End if
Strtemp = strtemp & request. servervariables ("SERVER_NAME ")
If request. servervariables ("server_port") <> 80 then strtemp = strtemp & ":" & request. servervariables ("server_port ")
Strtemp = strtemp & request. servervariables ("url ")
If trim (request. querystring) <> "then strtemp = strtemp &"? "& Trim (request. querystring)
Geturl = strtemp
Geturl = mid (geturl, instr (geturl ,"? ") + 1)
End Function

example: http: // 127.0.0.1/Shiyan. asp? Dfsdfsf = dsfsdfd & aa = dddd
: dfsdfsf = dsfsdfd & aa = dddd

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.