如何将asp的url编码函数更改为asp.net

如何将asp的url编码函数更改为asp.net,asp.net,asp-classic,url-encoding,Asp.net,Asp Classic,Url Encoding,如何将asp中的urlencode函数更改为asp.net Function URLEncode Dim StrTemp, StrChar Dim IntPos, IntKey StrTemp = "" StrChar = "" For IntPos = 1 To Len(encodeString) IntKey = Asc(Mid(encodeString, IntPos, 1))

如何将asp中的urlencode函数更改为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
函数URLEncode
暗淡的StrTemp,StrChar
调暗IntPos、IntKey
StrTemp=“”
StrChar=“”
对于IntPos=1到Len(编码字符串)
IntKey=Asc(Mid(编码字符串,IntPos,1))
如果IntKey=32,则
StrTemp=StrTemp&“+”
ElseIf((IntKey<123)和(IntKey>96))然后
StrTemp=StrTemp&Chr(IntKey)
ElseIf((IntKey<91)和(IntKey>64))然后
StrTemp=StrTemp&Chr(IntKey)
ElseIf((IntKey<58)和(IntKey>47))然后
StrTemp=StrTemp&Chr(IntKey)
其他的
StrChar=修剪(十六进制(内键))
如果IntKey<16,则
StrTemp=StrTemp&%0&StrChar
其他的
StrTemp=StrTemp&“%”和StrChar
如果结束
如果结束
下一个
返回StrTemp
端函数

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

asp.net有一个内置的URL编码方法,请检查


希望对您有所帮助。

我不能使用此选项,因为我想得到asp和asp.NET相同的结果。可能的重复项