The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

asp.net sample code error

Highlighted
Occasional Visitor

asp.net sample code error

Hi, I just downloaded the asp.net c# sample code.

when I try to add a contact using the AddContactSmallForm.aspx,

I got an error stopped at ContactComponent.cs line#963

"data.AppendFormat("<OptInSource>{0}</OptInSource>", optSourceNames[contact.OptInSource]);"

with the error message of "The given key was not present in the dictionary."

 

Just wondering anything I am missing here or any update in the code I missed?

 

Thanks!

 

Liu

3 REPLIES 3
Highlighted
Moderator

Re: asp.net sample code error

 
Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Visitor

Re: asp.net sample code error

Hi Dave,

 

Why I don't see anything in your reply? thanks!

Highlighted
Moderator

Re: asp.net sample code error

Sorry for that Liu, must have been a problem when I posted the reply.

 

The problem looks to be that you are not setting the contact.OptInSource to a valid value.  This is causing the lookup in the optSourceName dictionary to fail and causing your code to throw an exception.

 

I would recommend making sure that you are setting the contact.OptInSource to a valid value.  Leaving it null would also cause the dictionary lookup to fail. 

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured