episerver

EpiServer : How to Check Whether Page Exists?


Is there a way to gracefully check whether a page exists in EpiServer CMS 5 (given a pageId integer) without having to catch the PageNotFoundException thrown by

DataFactory.Instance.GetPage(pageReference)

(EpiServer will happily create a PageReference using a non existing pageId).

Surely I can check whether a page exists without throwing an exception or doing a massive loop?


Solution

  • [EPiServer CMS 5 R2 SP2] No, not without bypassing the page cache and that is more expensive than catching the exception.