?
Solved

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

Posted on 2004-09-23
7
Medium Priority
?
250 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

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…
Hey fellow admins! This time, I have a little fairy tale for you. As many tales do, it starts boring and then gets pretty gory. I hope you like it. TL;DR: It is about an important security matter, you should read it if you run or administer Windows …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

800 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