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
Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 Tell If Two Executable Files are the Same That Are Compiled from C++ 14 632
writing Bios 6 448
MIPS Assembly Language 3 794
recovering cyptowalled files 2 964
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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