Search code examples
c#asp.netasp.net-mvcepiserver-7

How to solve the following error: Episerver.PageBase does not contain a Constructor that takes 0 arguments


I have created a generic handler in a Episerver 7.5 project.

In this handler i want to inherit methods from the PageBase Class. My code looks like this:

public class GetMapCoordinates : PageBase, IHttpHandler
{
    public override void ProcessRequest(HttpContext context)
    {
        PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
        PropertyCriteria criteria = new PropertyCriteria();
        criteria.Condition = CompareCondition.Equal;
        criteria.Name = "PageTypeID";
        criteria.Type = PropertyDataType.PageType;
        criteria.Value = Locate.ContentTypeRepository().Load("HotelDetailPage").ID.ToString();
        criteria.Required = true;

        criterias.Add(criteria);

        PageDataCollection _newsPageItems = Locate.PageCriteriaQueryService().FindPagesWithCriteria(PageReference.StartPage, criterias);
    }

    public new bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

I have been trying to find other classes that inherit from the PageBase class but I have not been able to find it. I can not modify the PageBase class since it is locked as metadata in the project.

Is there another way arround this? Note that I said that I can not modify the PageBase class and add a constructor.


Solution

  • I have been at this since yesterday but minutes after puting the question here i found the answer...

    Apperently episerver has a class called "SimplePage" that inherits the PageBase class.

       public class GetMapCoordinates : SimplePage, IHttpHandler
        {
            public override void ProcessRequest(HttpContext context)
            {
                PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
                PropertyCriteria criteria = new PropertyCriteria();
                criteria.Condition = CompareCondition.Equal;
                criteria.Name = "PageTypeID";
                criteria.Type = PropertyDataType.PageType;
                criteria.Value = Locate.ContentTypeRepository().Load("HotelDetailPage").ID.ToString();
                criteria.Required = true;
    
                criterias.Add(criteria);
    
                PageDataCollection _newsPageItems = Locate.PageCriteriaQueryService().FindPagesWithCriteria(PageReference.StartPage, criterias);
            }
    
            public new bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }