English 中文(简体)
EpiServer : How to Check Whether Page Exists?
原标题:
  • 时间:2009-11-20 14:47:57
  •  标签:
  • episerver

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?

最佳回答

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

问题回答

I find it nice to do the catching in an extension method:

public static bool TryGetPage(this PageReference pageReference, out PageData pd)
{
    try
    {
        pd = DataFactory.Instance.GetPage(pageReference);
        return true;
    }
    catch (Exception)
    {
        pd = null;
        return false;
    }
}




相关问题
pasteHTML removes markup

I am writing a plugin to an old IE-only WYSIWYG-editor which resides in an old CMS. I ve created a plugin that opens an popup where the user can enter the url of an youtube clip. The popup then ...

What are the steps to creating a new EPiServer Project

How do you go about setting up a new EPiServer website? I can t seem to get from an empty visual studio project to a deployed website without having to fix all kinds of file path and referencing ...

Setting up a new EPiServer 6 project with source control

I want to end up with a single VS project/solution that I can check in to source control, that any other developer in the office can simply check out and run, and that I can deploy without having to ...

Search Server 2010 - reference error

Im running Search Server 2010 from a virtual machine and it works good so far. On my development machine (win xp 32bit), the thought is to query the search server with a web service. Problem is that ...

Development environment for ASP.NET with EpiServer

At our company we are going to develop more for the Windows platform than we have done up until now. As this scale of Windows development is new to us it would be nice with some feedback from ...

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(...

热门标签