can't get list subscribe to work with page redirect

Dec 4, 2010 at 12:31 AM

We have a .Net join page that includes a selection for adding a user to a mailchimp mailing list. After the user "joins" they're redirected to their personal overview page. If we keep the person on the page the listsubscribe works fine. If we do the redirect and the page doesn't postback it doesn't do the subscribe.

Does anyone have any ideas on how we can make this work while keeping the redirect?


Dec 4, 2010 at 1:55 AM

Need more info, but...

Are you using the api method  listSubscribe() ? or using a web sign-up form to post to the list?

How are you doing the redirect - response.redirect?  How are you checking that the listSubscribe() has completed successfully before doing the redirect?

My guess from your description is that you're in effect trying to do 2 actions in a single button click; the listSubscribe() api call or subscribe form ( HTTP POST), and then a redirect (essentially an HTTP GET)
-- ain't gonna happen if you're using standard submit button type behavior.

My suspicion is that you'll want to do an HTTPWebRequest for the listSubscribe(), examine the results for success, and then invoke a response.redirect if all is well or stay on the 'source' page if an error/exception is encountered.




Dec 4, 2010 at 2:08 AM

Thanks for the input David.

I think you may be on to something but let me add some detail if you don't mind to get your opinion if there's a work around.

We have a join page and on the page there is a checkbox a user can select to subscribe to a mailchimp list. if the box is checked and the user clicks the join button the code behind does a bunch of other stuff and then runs listSubscribe() and then response.redirects to the user's personalized home page.

If we comment out the response.redirect the listSubscribe() works fine and if we look at the mailchimp list we can see the user has been added. If we keep the response.redirect the user is not added to the mailchimp list.

The biggest noticable difference is that without the response.redirect the "join" button click causes the join page to postback and of course with the redirect it doesn't as it leaves the page.

The only mailchimp related code on the page is the listSubscribe() and the assemblies of course.

thanks in advance for any thoughts you may have.


Dec 4, 2010 at 2:37 AM

My guess is that you're not using my wrapper, and if true, how are you invoking the listSubscribe() api call?

I just ran a test with my wrapper running from my dev machine, successfully subscribed to a list, and then redirected to my external website.

I'm not a great network guru, but my best guess here is that when you issue the redirect, that's overwriting the http headers so you're losing the post request & information because the response is buffered.

I've never actually tried it, but perhaps you can get around that somehow without using HttpWebRequest -- but doing a HttpWebRequest is pretty straightforward.


Dec 6, 2010 at 6:36 PM

Turned out to be a very stupid mistake on my side. Deep in the save code there was an early call to the redirect so it was actually hitting that before it got to the listsubscribe.

All is working as expected now with the list subscribe combined with the redirect.

Thanks for all of the help and sorry for the wild goose chase.


Dec 7, 2010 at 7:22 PM

hey - no problem -- I've had my share of stupid this week too :-) 


Have a good one,