2011-06-27 18 views
-1

如何改變這種用urlencode功能ASP到ASP.NET如何改變URL編碼功能的ASP到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 

我不知道該如何ASP改爲asp.net。

+0

[編碼功能,支持Unicode和工作在asp和asp.net]可能的副本(http://stackoverflow.com/questions/6491550/encoding-function-that-supports-unicode-and-works-in -both-asp-and-asp-net) –

回答

0

Asp.Net有一個內置的URL編碼方法,檢查HttpServerUtility.UrlEncode

希望有所幫助。

+0

我不能使用這個,因爲我想得到同樣的結果asp和asp.net – zanhtet