Determine whether SimplePage is a CMS page

Vote:
 

I have an static ASPX file in my website which inherits from SimplePage.

By inheriting from SimplePage, when I peform ((System.Web.HttpContext.Current.Handler)EPiServer.PageBase).CurrentPage, I get a reference to the start page which is what I want.

I need to however determine whether the current page is a real CMS page or not.

Other than taking the current url and trying to map to an internal page, is there any other way of doing this?

Thanks,

Adam

#60303
Aug 03, 2012 12:28
Vote:
 

Hi Adam,

I just got back from vacation so I might have miss understod your question. But if not something like this would work no?

var currentPage = CurrentPage as SimplePage

if( currentPage !=null)

%YourMagicHere%

#60308
Aug 03, 2012 13:53
Vote:
 

Hi Petter,

Not quite, but actually I can use the same approach and try cast to TemplatePage.

var page = System.Web.HttpContext.Current.Handler as EPiServer.PageBase;

if (page != null && page.CurrentPage != null)
{
	// We are either on a CMS generated page or a static aspx page which inherits from SimplePage.
	
	if(page is TemplatePage)
	{
		// A page generated by CMS.
	}
}

Cheers,

Adam

#60327
Aug 06, 2012 9:41
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.