开发者

How to change url encode function for asp to asp.net

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜