8

I have created a MVC 4 Application and followed the setup procedure for DD4T. Once I run my website it gives off an error "No PageFactory Configured". I've read the issue about this problem on this forum earlier, but what solves that problem, doesn't solve mine.

I've added all the Tridion dll's to the bin directory including the Content Delivery dll's. Configuration added to the config folder inside the bin directory and added jars to the lib directory.

The web.config has the PageFactory configured, but this error is still occuring. Using DD4T 1.31, MVC4 and Tridion 2013.

Also, I'm using the Visual Studio Template as a guide, I've setup my own MVC4 project.

Any ideas? Am I missing something?

EDIT:

My Web.Config:

<configuration>
  <configSections>
    <!-- MS Unity config section -->
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />

    <!-- DD4T Settings -->
    <!-- Websites -->
    <add key="Site.ActiveWebsite" value="Foo.NL"/>
    <!--add key="Site.ENWebsite" value="Foo.EN"/-->

     <!-- Publication Mappings -->
    <add key="WebSite.Foo.NL.PublicationId" value="8"/>
    <!--add key="WebSite.Foo.EN.PublicationId" value="9"/-->

    <!-- Index file -->
    <add key="DD4T.WelcomeFile" value="index.html"/>


    <!-- Basic DD4T Configuration Settings -->
    <add key="DD4T.ComponentPresentationController" value="Component"/>
    <add key="DD4T.ComponentPresentationAction" value="ComponentPresentation"/>
  </appSettings>
  <system.web>
    <httpRuntime targetFramework="4.5.1" />
    <compilation debug="true" targetFramework="4.5.1" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </roleManager>
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <!-- Unity configuration -->
  <unity>
    <typeAliases>

      <!-- Lifetime manager types -->
      <typeAlias alias="singleton"
                 type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,
                     Microsoft.Practices.Unity" />
      <typeAlias alias="external"
                 type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,
                     Microsoft.Practices.Unity" />

      <!-- define aliases for interfaces -->
      <typeAlias alias="IPageProvider"
                 type="DD4T.ContentModel.Contracts.Providers.IPageProvider, DD4T.ContentModel.Contracts" />
      <typeAlias alias="IComponentProvider"
                 type="DD4T.ContentModel.Contracts.Providers.IComponentProvider, DD4T.ContentModel.Contracts" />
      <typeAlias alias="IBinaryProvider"
                 type="DD4T.ContentModel.Contracts.Providers.IBinaryProvider, DD4T.ContentModel.Contracts" />
      <typeAlias alias="ILinkProvider"
                 type="DD4T.ContentModel.Contracts.Providers.ILinkProvider, DD4T.ContentModel.Contracts" />
      <typeAlias alias="ITaxonomyProvider"
                 type="DD4T.ContentModel.Contracts.Providers.ITaxonomyProvider, DD4T.ContentModel.Contracts" />
      <typeAlias alias="IComponentPresentationRenderer"
                 type="DD4T.Mvc.Html.IComponentPresentationRenderer, DD4T.Mvc" />
      <typeAlias alias="IPageController"
           type="DD4T.Mvc.Controllers.IPageController, DD4T.Mvc" />
      <typeAlias alias="IComponentController"
           type="DD4T.Mvc.Controllers.IComponentController, DD4T.Mvc" />
      <typeAlias alias="IPageFactory"
                 type="DD4T.ContentModel.Factories.IPageFactory, DD4T.ContentModel.Contracts" />
      <typeAlias alias="IComponentFactory"
                 type="DD4T.ContentModel.Factories.IComponentFactory, DD4T.ContentModel.Contracts" />
      <typeAlias alias="ILinkFactory"
                 type="DD4T.ContentModel.Factories.ILinkFactory, DD4T.ContentModel.Contracts" />




      <!-- 
        Define aliases for implementations 
        This is where we determine which classes to use for our implementations!
      -->
      <typeAlias alias="PageProvider"
                 type="DD4T.Providers.SDLTridion2013.TridionPageProvider, DD4T.Providers.SDLTridion2013" />
      <typeAlias alias="ComponentProvider"
                 type="DD4T.Providers.SDLTridion2013.TridionComponentProvider, DD4T.Providers.SDLTridion2013" />
      <typeAlias alias="BinaryProvider"
                 type="DD4T.Providers.SDLTridion2013.TridionBinaryProvider, DD4T.Providers.SDLTridion2013" />
      <typeAlias alias="LinkProvider"
                 type="DD4T.Providers.SDLTridion2013.TridionLinkProvider, DD4T.Providers.SDLTridion2013" />
      <typeAlias alias="TaxonomyProvider"
                 type="DD4T.Providers.SDLTridion2013.TridionTaxonomyProvider, DD4T.Providers.SDLTridion2013" />
      <typeAlias alias="ComponentPresentationRenderer"
           type="DD4T.Mvc.Html.DefaultComponentPresentationRenderer, DD4T.Mvc" />
      <typeAlias alias="PageController"
           type="Foo.DD4T.PageController, Foo.DD4T" />
      <typeAlias alias="ComponentController"
           type="Foo.DD4T.ComponentController, Foo.DD4T" />

      <typeAlias alias="PageFactory"
                 type="DD4T.Factories.PageFactory, DD4T.Factories" />

      <typeAlias alias="ComponentFactory"
                 type="DD4T.Factories.ComponentFactory, DD4T.Factories" />
      <typeAlias alias="LinkFactory"
                 type="DD4T.Factories.LinkFactory, DD4T.Factories" />



    </typeAliases>

    <!-- Unity Configuration -->
    <containers>
      <container name="main">
        <types>
          <!-- map the implementations to the interfaces -->
          <type type="IPageProvider" mapTo="PageProvider">
            <!--          <lifetime type="singleton" /> -->
            <property name="PublicationId" type="int" value="8"/>
          </type>
          <type type="IPageFactory" mapTo="PageFactory">
            <property name="PageProvider" dependencyType="IPageProvider"/>
            <property name="ComponentFactory" dependencyType="IComponentFactory"/>
            <property name="LinkFactory" dependencyType="ILinkFactory"/>
          </type>
          <type type="ILinkProvider" mapTo="LinkProvider" />
          <type type="ILinkFactory" mapTo="LinkFactory">
            <property name="LinkProvider" dependencyType="ILinkProvider"/>
          </type>
          <type type="IPageController" mapTo="PageController">
            <property name="PageFactory" dependencyType="IPageFactory"/>
            <property name="ComponentPresentationRenderer" dependencyType="IComponentPresentationRenderer"/>
          </type>
          <type type="IComponentProvider" mapTo="ComponentProvider">
            <lifetime type="singleton" />
          </type>
          <type type="IComponentFactory" mapTo="ComponentFactory">
            <lifetime type="singleton" />
            <property name="ComponentProvider" dependencyType="IComponentProvider"/>
          </type>
          <type type="IComponentController" mapTo="ComponentController">
            <property name="ComponentFactory" dependencyType="IComponentFactory"/>
          </type>
          <type type="IComponentPresentationRenderer" mapTo="ComponentPresentationRenderer">
            <lifetime type="singleton" />
          </type>
        </types>
      </container>
    </containers>
  </unity>
  <!-- end Unity configuration-->
</configuration>
2
  • This can sometimes happen if your licence is invalid or you didn't put the provider DLLs in the bin directory. Commented Nov 12, 2013 at 17:32
  • License is valid and pointing to the correct location and the provider dll is also there.
    – Thijs
    Commented Nov 12, 2013 at 18:14

2 Answers 2

7

Ok, I found out that it was still the Tridion.ContentDelivery.dll. It was present, but it was a different version than my Provider dll was built against. So the provider did not want to load it.

See the comments on the previous answer to see how the fix was done.

A great way to test is to load the unity (or whatever framework you use) configuration to test the config:

var factory = container.Resolve<IPageFactory>();

Thanks Quirijn and Neil!

5

Have you configured an IoC container?

I haven't used the Visual Studio template but the expectation is that your using some kind of IoC (Ninject, Castle.Windsor, Unity) within your MVC project and therefore you configure this to inject the correct implementation of all the DD4T factories etc.

Example Castle.Windsor config:

<component id="IPageFactory" service="DD4T.ContentModel.Factories.IPageFactory, DD4T.ContentModel.Contracts" lifestyle="singleton" type="DD4T.Factories.PageFactory, DD4T.Factories">
    <parameters>
      <PageProvider>${IPageProvider}</PageProvider>
      <ComponentFactory>${IComponentFactory}</ComponentFactory>
      <LinkFactory>${ILinkFactory}</LinkFactory>
    </parameters>
  </component>
8
  • Yes, as I mentioned before, I've used the Visual Studio Template as a guide and copied the Unity configuration over to my project.
    – Thijs
    Commented Nov 12, 2013 at 16:22
  • So when you debug your project in Visual Studio can you ascertain that Unity is wired up correctly and a PageFactory object can be resolved? Apologies, as I say I haven't used the template but your error suggests Unity is not configured correctly.
    – Neil
    Commented Nov 12, 2013 at 16:53
  • I've checked with a breakpoint on Application_Start() that it is actually loading the unity configuration.
    – Thijs
    Commented Nov 12, 2013 at 16:59
  • If you put a breakpoint in the method PageController.Page, does it get hit and does the controller's PageFactory property have a value?
    – Quirijn
    Commented Nov 12, 2013 at 17:32
  • No all properties are null.
    – Thijs
    Commented Nov 12, 2013 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.