ASP obtains a summary of the url function. Friends who need it can refer to it. Method 1: Simple, no parameters, only a virtual path
Copy the code code as follows:
GetUrl =request(url)
For example: http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
Obtained as: shiyan.asp
Copy the code code as follows:
<%
dim changdu,url,ends,wurl
changdu=len(request.ServerVariables(URL))
url=instrrev(request.ServerVariables(URL),/)
url=url+1
ends=changdu+1-url
wurl=mid(request.ServerVariables(URL),url,ends)
%>
Method 2: Get the entire URL and get the parameters
Copy the code code 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
For example: http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
Obtained as: http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
Method 3: Get the virtual path and get the parameters
Copy the code code as follows:
Private Function GetUrl()
Dim ScriptAddress,M_ItemUrl,M_item
ScriptAddress = CStr(Request.ServerVariables(SCRIPT_NAME)) 'Get 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 parameters of Page_num (this parameter is set by itself in page_turn.asp and changes according to personal settings), otherwise this will be superimposed every time the page is turned. Parameters, although they do not affect the function, are still 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
For example: http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
Obtained as:/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
Method 4: Get only the parameter string
Copy the code code 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
For example: http://127.0.0.1/shiyan.asp?dfsdfsf=dsfsdfd&aa=dddd
Obtained as: dfsdfsf=dsfsdfd&aa=dddd