d2fox
asked on
how to use urlencode in asp and asp.net
In my asp.net registration page, I use Server.UrlEncode(TextEmail .Text) to store the email address. In the 'forgot my password', which is written in asp, i use Server.UrlEncode(TextEmail .Text) to retrieve the email address. But they don't match.
The first page stores bbb%40b.com when the user registers (asp.net)
The asp page requests the account for the email address 'bbb%40bbb%2Ecom (asp)
Same exact email address entered (bbb@bbb.com)
How can i resolve this?
The first page stores bbb%40b.com when the user registers (asp.net)
The asp page requests the account for the email address 'bbb%40bbb%2Ecom (asp)
Same exact email address entered (bbb@bbb.com)
How can i resolve this?
check here for more info : http://msdn.microsoft.com/en-us/library/6196h3wt.aspx
ASKER
Sorry, I don't want to DECODE. I have encoded it when i stored it (from asp.net), and it's stored as bbb%40b.com in the database as a result of my encoding. Then another page (classic asp) wants to find this record. So it URLENCODES again, and it requests the SQL record containing bbb%40bbb%2Ecom.
My issue is that in the first case, the PERIOD is not encoded. In the second it is. SO the record is not found based on email address. This is a problem. I want them to match.
My issue is that in the first case, the PERIOD is not encoded. In the second it is. SO the record is not found based on email address. This is a problem. I want them to match.
HainKurt is right. UrlDecode before your compare the email addresses.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can decode it first, and store MD5 into your DB
It looks like you only want to fix the dot '.' issue. You can just replace the strings either in the ASP side or ASP.NET side.
string str = Server.UrlEncode("bbb@bbb. com");
str=str.Replace(".","%2E") ;
string str = Server.UrlEncode("bbb@bbb.
str=str.Replace(".","%2E")
Server.UrlDecode(TextEmail