Try our conversational search powered by Generative AI!

Issue with unsubscribing


I'm trying to create an unsubscribe feature via email link from the subscription emails that are sent out.  The unsubscribe link contains the GUID of the Membership User and this is used to retrieve the EPiServer user profile:

MembershipUser member = Membership.GetUser(Guid.Parse(userGuidStr));

EPiServerProfile user = EPiServerProfile.Get(member.UserName);

Then all PageReferences in user.SubscriptionInfo.ListSubscriptions are passed to user.SubscriptionInfo.UnSubscribe and finally user.Save is called.  

However, when the EPiServer.Web.WebControls.SubscriptionList is still has items checked as subscribed to.  It is expected that all items in the subscriptionList will be unchecked.  

When I step through the loop of pagereferences being unsubscribed the user.SubscriptionInfo reflects the items being removed. But when the subscriptionList web control renders they're all back there :-(

I have attempted moving the unsubscribe code to overrides of the onInitComplete and even onPreInit events so that the work is complete before the subscriptionList is bound - but to no avail.

Any pointers as to where I'm going wrong with this would be appreciated.


Nov 11, 2013 0:15

Might be that you need to specify the languagebranch of the page you're unsubscribing, like so:

user.SubscriptionInfo.Unsubscribe(yourpageref, "en"); // must be the same language code that you subscribed to



Edited, Nov 11, 2013 11:36

Thanks Arild - but no dice.

I had encountered that UnSubscribe must match the language.  Regardless I had covered that at one stage by being tripley sure:

user.SubscriptionInfo.UnSubscribe(pageRef, "en")
user.SubscriptionInfo.UnSubscribe(pageRef, "EN")

I think (but clearly am not certain about things here) that it is tied to the SubscriptionList web control binding before I remove the subscriptions.  My next approach will be to redirect FROM a service that does the initial UnSubscribe TO the page with the subscription list control.  I know that the Unsubscribe works in other customised circumstances but am bamboozled by this one.  Will report back after implementing the redirection approach - but currently on different task.

Edited, Nov 19, 2013 1:13

My point was that if a language branch was specified when you SUBSCRIBED to the pages (e.g. user.SubscriptionInfo.Subscribe(pageref, "en")) then you'd need to specify the language branch when UNSUBSCRIBING, too. See

To verify, check your aspnet_Profile table. It should contain an xml string that includes a <SubscribedPages> element. If a language branch was specified it should contain a <Languages> element.

Regarding your theory in databinding, you should be able to debug that easily by checking the database xml string mentioned above when stepping through your code after the unsubscribe() call to see if the page was successfully unsubscribed.


Edited, Nov 19, 2013 8:56
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.