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?
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: |
Hi Raquel,
Have you included the 'Episerver,Sample.YouTubeProvider' project in your local solution and it's rebuilding successfully?
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
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);
providerManager.ProviderMap.AddProvider(catalogProvider);
}
I agree with Quan post for more help you can try below example:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
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);
contentProviderManager.ProviderMap.AddProvider(provider);
}
}
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.
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!
Hello all,
I am trying to add an example content provider, https://github.com/episerver/YouTubeContentProvider, 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