Try our conversational search powered by Generative AI!

unable to cast pagedata to pagetype



I am using episerver 6 r 2 cms.

I am trying to fetch all my news pages in my site using the following code. I am getting an error - unable to cast pagedatat to news pagte type. I heard, it is a bug in episever 6 r2 cms, some people suggested to use AsTyped() but I tried TryAsTyped() didn't work. 

Any help would be appreciated !!


var criterias = new PropertyCriteriaCollection();
var criteria = new PropertyCriteria
Condition = CompareCondition.Equal,
Name = "PageTypeName",
Type = PropertyDataType.String,
Value = "NyhetsSida",
Required = true
var newsTemp = DataFactory.Instance.FindPagesWithCriteria(new PageRepository().GetNewsListPage(), criterias, EPiServer.Security.AccessLevel.Read).TryAsTyped();



Jun 24, 2013 1:42

First you should use Type = PropertyDataType.PageType.

Second, could you identify which page(s) are throwing the exception? What Page Type they are and what Page Type Class they should be and whether AsTyped() or TryAsTyped() is trying to cast them to another Page Type Class?

Edited, Jun 24, 2013 9:16
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.