如何更改asp到asp.net的url编码功能

时间:2011-06-27 09:52:32

标签: asp.net asp-classic url-encoding

如何在asp到asp.net中更改此urlencode函数

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

我不知道如何将asp更改为asp.net。

1 个答案:

答案 0 :(得分:0)

Asp.Net有一个编码网址的内置方法,请检查HttpServerUtility.UrlEncode

希望有所帮助。