SaaS CMS has officially launched! Learn more now.

Registering a custom content provider


Hello all, 

I am trying to add an example content provider,, and have added it to my local solution. I am now trying to register the content provider and have added the following to my web.config.


The YouTubeProvider class has the following structure:

namespace EPiServer.Sample.YouTubeProvider
    public class YouTubeProvider : ContentProvider
        #region Fields

        private readonly ServiceAccessor

Jan 13, 2021 0:07

My original post got truncated. My issue is that when I add a registration for a content provider in the web.config, the site produces an error that it can't load the provider type. I have created a blank class and tried to register that with the same results. Any suggestions on what I may be missing?

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Provider type 'Org.Business.TestProvider, Org.Business' could not be loaded.

Source Error:

Line 406:    
Jan 13, 2021 1:00

Hi Raquel,

Have you included the 'Episerver,Sample.YouTubeProvider' project in your local solution and it's rebuilding successfully?

Jan 13, 2021 16:28

Have you registered your content provider, something like this (in an initialization module)

        private static void InitializeContentProvider(InitializationEngine context)
            var providerManager = context.Locate.Advanced.GetInstance

Jan 14, 2021 10:43
Quan Mai - Jan 14, 2021 13:20
private static void InitializeContentProvider(InitializationEngine context)
var providerManager = context.Locate.Advanced.GetInstance

        private static void InitializeContentProvider(InitializationEngine context)
            var providerManager = context.Locate.Advanced.GetInstance<IContentProviderManager>();
            var catalogProvider = context.Locate.Advanced.GetInstance<CatalogContentProvider>();
            var settings = new NameValueCollection
                {ContentProviderElement.EntryPointString, 0.ToString()}
            catalogProvider.Initialize(CatalogContentProvider.DefaultProviderKey, settings);

Jan 14, 2021 13:23

I agree with Quan post for more help you can try below example:

    public class YouTubeProviderInitializer : IInitializableModule
        public void Initialize(Framework.Initialization.InitializationEngine context)
			// Create provider root if not exists
			var contentRepository = context.Locate.ContentRepository();
			var youTubeRoot = contentRepository.GetBySegment(SiteDefinition.Current.RootPage, YouTubeSettings.ProviderName, LanguageSelector.AutoDetect(true));
			if (youTubeRoot == null)
				youTubeRoot = contentRepository.GetDefault<ContentFolder>(SiteDefinition.Current.RootPage);
				youTubeRoot.Name = YouTubeSettings.ProviderName;
				contentRepository.Save(youTubeRoot, SaveAction.Publish, AccessLevel.NoAccess);

                        // Register provider
			var contentProviderManager = context.Locate.Advanced.GetInstance<IContentProviderManager>();
			var configValues = new NameValueCollection { {ContentProviderElement.EntryPointString, youTubeRoot.ContentLink.ToString()} };
	                var provider = context.Locate.Advanced.GetInstance<YouTubeProvider>();
			provider.Initialize(YouTubeSettings.ProviderKey, configValues);
Jan 14, 2021 15:32

Thanks for the replies. 

The content provider has registered now when I added the code in the initialization module. 

To clarify, there are 2 ways to do this, right? So either add via the initialization module or web.config? 

I currently have both in place. 

Jan 15, 2021 4:45

Thanks @Sanjay Kumar and @Quan Mai. Can't find the tick mark to mark your reply as the answers but your response helped me, much appreciated! 

Jan 28, 2021 22:42
Quan Mai - Jan 29, 2021 9:12
I marked the posts as answer. Glad to hear it helped
Sanjay Kumar - Jan 29, 2021 9:38
Thanks Quan :)
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.