Skip to content

Instantly share code, notes, and snippets.

@miklund
Last active January 15, 2016 19:17
Show Gist options
  • Save miklund/63886c4051626ee9f2a6 to your computer and use it in GitHub Desktop.
Save miklund/63886c4051626ee9f2a6 to your computer and use it in GitHub Desktop.
2008-11-20 EPiServer: Page Not Found!
# Title: EPiServer: Page Not Found!
# Author: Mikael Lundin
# Link: http://blog.mikaellundin.name/2008/11/20/episerver-page-not-found.html
public class Global : EPiServer.Global
{
public void Application_Start(object sender, EventArgs e)
{
DataFactory.Instance.DeletingPage += new PageEventHandler(UnsubscribePage);
}
public static void UnsubscribePage(object sender, PageEventArgs e)
{
int i = 0;
int totalPages = 0;
ProfileInfoCollection profiles =
ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All, i++, 100, out totalPages);
foreach (ProfileInfo profile in profiles)
{
EPiServerProfile epProfile = EPiServerProfile.Get(profile.UserName);
epProfile.SubscriptionInfo.UnSubscribe(e.PageLink);
}
}
}
public static PageExists(this DataFactory instance, PageReference pageLink)
{
try { DataFactory.Instance.GetPage(pageLink); return true; }
catch (PageNotFoundException) { return false; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment