-1

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.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
zanhtet
  • 2,040
  • 7
  • 33
  • 58
  • possible duplicate of [Encoding function that supports unicode and works in both asp and asp.net](http://stackoverflow.com/questions/6491550/encoding-function-that-supports-unicode-and-works-in-both-asp-and-asp-net) – Joel Coehoorn Nov 18 '11 at 14:46

1 Answers1

0

Asp.Net has a built-in method to Encode URLs, check HttpServerUtility.UrlEncode.

Hope that helps.

Ken D
  • 5,880
  • 2
  • 36
  • 58