Solved

How do i Server.URLEncode in VB and decode in ASP?

Posted on 2004-09-23
7
248 Views
Last Modified: 2008-01-09
I'm writing a VBB app that creates the URL to direct the client. I need to URL Encode in VB and decode it the asp page. Any smart people out there know how to accomplish this? I tried a function i got from the net for VB to encode and then used unescape() in asp but strings dont match! How do i find the source code for escape() and code it in VB? This is the function that doesn't work!

Public Function URLEncode(StringToEncode As String, Optional _
   UsePlusRatherThanHexForSpace As Boolean = False) As String

Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToEncode)
  Select Case Asc(Mid(StringToEncode, CurChr, 1))
    Case 48 To 57, 65 To 90, 97 To 122
      TempAns = TempAns & Mid(StringToEncode, CurChr, 1)
    Case 32
      If UsePlusRatherThanHexForSpace = True Then
        TempAns = TempAns & "+"
      Else
        TempAns = TempAns & "%" & Hex(32)
      End If
   Case Else
         TempAns = TempAns & "%" & _
              Format(Hex(Asc(Mid(StringToEncode, _
              CurChr, 1))), "00")
End Select

  CurChr = CurChr + 1
Loop

URLEncode = TempAns
End Function
0
Comment
Question by:philip07
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:avi247
ID: 12137462

1. Try these
http://www.devx.com/vb2themax/Tip/19353
http://vbnet.mvps.org/index.html?code/internet/urlescape.htm

Looks like you are using the URLEncode from this site
http://www.freevbcode.com/ShowCode.asp?ID=1512
Try using their URLDecode method to decode instead of unescape()

2. If it still does not work,
Give us an example URL thats not working for you, and your code for the string comparison.
0
 
LVL 10

Expert Comment

by:anv
ID: 12140175
0
 

Author Comment

by:philip07
ID: 12149345
OK, here we go, in VB I encrypt string "some string to encrypt" with key "mypass" using rc4 method and the encrypted result is: ±¯Ä‹¯šš¥ýb70
½h}¸ and the encoded is %B1%AF%C4%F%8B%AF%03%8D%00%00%A5%FDb70%A%BDh%7D%B8%1C%06
So i plug in the encoded string in a URL in asp and Decoded comes out as ±¯ÄF‹¯ and the DeCrypted som, str

I used the VB URLEncode and the URLDecode in asp even though i don't need to since Explored decodes it allready. The asp code Decrypts correctly but it doesn't get the full string to decrypt. What the problem is???


0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12642534
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 

Author Comment

by:philip07
ID: 12687793
Sorry, but noone gave me a valid solution to this problem. I solved it myself, noone should get any points for it.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Converting Native Code to VB or C# 9 1,466
convert array of bytes  into hex string and back 11 651
memory mapped I/O query 6 161
ia32 assembly to c 3 490
A lot of things can happen during a presentation, worst of which is “death by PowerPoint.” Here are a few mistakes to avoid to make your slides clean.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question