Try our conversational search powered by Generative AI!

Dependency injection with page types

Vote:
 

Is is possibel to use depnedcy injection with page type. I'm trying  to do the following

        private ISiteSettings _siteSettings;

        public ProductPageBase(ISiteSettings siteSettings)
        {
            _siteSettings = siteSettings;
        }

But i am getting the following error

Type 'Cds.Nitb.Web.Models.Pages.Product.ActivityPage' does not have any public default constructor and no IConstructorParameterResolver that handles it

I know that ISiteSettings does work with DI (StructureMap) as I am using it elsewhere. Is there soemthing else I need to do to getting it working with page types.

Thanks

(Note- this could be an EPiServer Find nissue as the code crashes at the point where I do a find call - maybe not though)

 

 

 

 

   

 

 

Type 'Cds.Nitb.Web.Models.Pages.Product.ActivityPage' does not have any public default constructor and no IConstructorParameterResolver that handles it

#86051
May 13, 2014 9:45
Vote:
 
private readonly ISiteSettings _siteSettings;

public ProductPageBase(ISiteSettings siteSettings)
{
	_siteSettings = siteSettings;
}

public ProductPageBase()
{
	_siteSettings = ServiceLocator.Current.GetInstance<ISiteSettings>();
}

    

#86059
May 13, 2014 12:51
Vote:
 

Thanks the additional constructor is waht i needed.

Thanks for your help

#86495
May 22, 2014 15:13
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.