Verify Email URL Problem

Jul 15, 2009 at 7:34 PM

I ran into an issue with the verify email issue that I was able to resolve so wanted to share my fix. Basically, whenever I tried to navigate to the email verification link I would get the following error:

Invalid length for a Base-64 char array.

After doing some research and walking through the code I found that the server couldn't process the URL as it had some invalid characters. To resolve this I used UrlEncode on the encrypted user name before that gets used in the verification link. This encodes the encrypted text in a form readable by the server.

Here's the changed code in the Email.cs file:

 

        public void SendEmailAddressVerificationEmail(string Username, string To)
        {
            // ORIGINAL
            //string msg = "Please click on the link below or paste it into a browser to verify your email account.<BR><BR>" +
            //                "<a href=\"" + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
            //                Username.Encrypt("verify") + "\">" +
            //                _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
            //                Username.Encrypt("verify") + "</a>";

            // 20070915, KRL: Changed to below to resolve "Invalid length for a Base-64 char array." error,
            // which occurs when server encounters and mangles invalid URL characters

            string urlEncodedText = HttpUtility.UrlEncode(Cryptography.Encrypt(Username, "verify"));
            
            string msg = "Please click on the link below or paste it into a browser to verify your email account.<BR><BR>" +
                            "<a href=\"" + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
                            urlEncodedText + "\">" +
                            _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
                            urlEncodedText + "</a>";

            SendEmail(To, "", "", "Account created! Email verification required.", msg);
        }

I hope this is helpful to someone.

Ken

 

 

 

Coordinator
Jul 15, 2009 at 9:12 PM

Great!  Thanks.

Aug 4, 2009 at 12:33 PM

Thanks kenlewisjr 

also need to add :

using System.Web;
in Email.cs file
Aug 4, 2009 at 1:16 PM

Another small mistake;

"Accounts" of

string msg = "Please click on the link below or paste it into a browser to verify your email account.<BR><BR>" +
                            "<a href=\"" + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
                            urlEncodedText + "\">" +
                            _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +
                            urlEncodedText + "</a>";

should be take place of "Account",because the folder name under "FisharooWeb" project  is "Account"  not "Accounts".

Aug 4, 2009 at 3:10 PM

Here's what I noticed. The book uses Account with no "s" while the downloadable code base, which I'm using, uses "Accounts".

Ken

 

Coordinator
Aug 4, 2009 at 7:52 PM
Should be accounts though. Might have been refactored in a later chapter.

From: [email removed]
Sent: Tuesday, August 04, 2009 6:16 AM
To: [email removed]
Subject: Re: Verify Email URL Problem [community:62538]

From: shijiesj

Another small mistake;

"Accounts" of

string msg = "Please click on the link below or paste it into a browser to verify your email account.

"
+ " + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" + urlEncodedText + "\">" + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" + urlEncodedText + "";

should be take place of "Account",because the folder name under "FisharooWeb" project is "Account" not "Accounts".

Oct 14, 2009 at 1:51 PM

but in chapter 5 ,when to click the link to verify.

the error:

Source Error:

Line 37: 
Line 38:             alert = new Alert();
Line 39:             alert.AccountID = account.AccountID;
Line 40:             alert.CreateDate = DateTime.Now;
Line 41:         }


Source File: C:\Projects\MyFisharoo_Chapter1-3\trunk\Source\FisharooCore\Core\Impl\AlertService.cs    Line: 39

Apr 30, 2010 at 3:42 AM

Hi there I just Adjust my smtp Account inside the app.config of both FisharooCore and FisharooMailQueueProcessor projects , I am using the free smtp service which is provided by Google but unfortunately I didn't get any email from system !!

Should I adjust any tools or other codes ?or is this work with Google smtp service ? please help me to get address of this problem ...

 

Coordinator
Apr 30, 2010 at 3:52 AM
Google SMTP operates on different ports and requires that you specify a handful of custom headers.

From: [email removed]
Sent: Thursday, April 29, 2010 8:42 PM
To: [email removed]
Subject: Re: Verify Email URL Problem [community:62538]

From: saeid3070

Hi there I just Adjust my smtp Account inside the app.config of both FisharooCore and FisharooMailQueueProcessor projects , I am using the free smtp service which is provided by Google but unfortunately I didn't get any email from system !!

Should I adjust any tools or other codes ?or is this work with Google smtp service ? please help me to get address of this problem ...

May 6, 2010 at 9:37 AM
Thanks I appreciate that