Solved

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

Posted on 2004-09-23
7
244 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to start solving phase 4 of binary bomb 12 5,166
MIPS Assembly Language 1 816
query on RISC/CISC binary on single hardware 5 544
Adding Crystal Report dll's from GAC 5 186
OpenVPN is a great open source VPN server that is capable of providing quick and easy VPN access to your network on the cheap.  By default the software is configured to allow open access to your network.  But what if you want to restrict users to on…
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

948 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now