Try our conversational search powered by Generative AI!

unable to cast pagedata to pagetype

Vote:
 

Hi, 

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
};
criterias.Add(criteria);
var newsTemp = DataFactory.Instance.FindPagesWithCriteria(new PageRepository().GetNewsListPage(), criterias, EPiServer.Security.AccessLevel.Read).TryAsTyped();

 

 

#72590
Jun 24, 2013 1:42
Vote:
 

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?

#72595
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.