How to change this urlencode function in asp to asp.net
Function URLEncode
Dim StrTemp, StrChar
Dim IntPos, IntKey
StrTemp = ""
StrChar = ""
For IntPos = 1 To Len(encodeString)
IntKey = Asc(Mid(encodeString, IntPos, 1))
开发者_运维知识库 If IntKey = 32 Then
StrTemp = StrTemp & "+"
ElseIf ((IntKey < 123) And (IntKey > 96)) Then
StrTemp = StrTemp & Chr(IntKey)
ElseIf ((IntKey < 91) And (IntKey > 64)) Then
StrTemp = StrTemp & Chr(IntKey)
ElseIf ((IntKey < 58) And (IntKey > 47)) Then
StrTemp = StrTemp & Chr(IntKey)
Else
StrChar = Trim(Hex(IntKey))
If IntKey < 16 Then
StrTemp = StrTemp & "%0" & StrChar
Else
StrTemp = StrTemp & "%" & StrChar
End If
End If
Next
Return StrTemp
End Function
I don't know how to change asp to asp.net.
Asp.Net has a built-in method to Encode URLs, check HttpServerUtility.UrlEncode.
Hope that helps.
精彩评论