I am trying to setup a new project using DD4T 2.0 .Net Solution with SDL Web 8.5. Here I have not used any micro services in web application to fetch the data. I am using cd_storage_config to connect to Broker Database.
When I run the application I encounter the below error in the code level :
An exception of type 'System.Web.HttpException' occurred in DD4T.MVC.dll but was not handled in user code
Additional information: Page cannot be found
I have followed this link while creating the DD4T solution. Below I am adding the basic information I have used in the solution
cd_storage_config :
<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="6.1" xsi:noNamespaceSchemaLocation="schemas/cd_storage_conf.xsd">
<Global>
<Storages>
<Storage Class="com.tridion.storage.persistence.JPADAOFactory" Id="defaultdb" Type="persistence" dialect="MSSQL">
<Pool CheckoutTimeout="120" IdleTimeout="120" MonitorInterval="60" Size="10" Type="jdbc"/>
<DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<Property Name="serverName" Value="<DB_Instance>"/>
<Property Name="portNumber" Value="1433"/>
<Property Name="databaseName" Value="Tridion_Broker_Staging"/>
<Property Name="user" Value="TridionBrokerUser"/>
<Property Name="password" Value="********"/>
</DataSource>
</Storage>
<!--
Configuration example for using filesystem as data storage.
-->
<Storage Class="com.tridion.storage.filesystem.FSDAOFactory" Id="defaultFile" Type="filesystem" defaultFilesystem="false">
<Root Path="D:\websites\staging"/>
</Storage>
</Storages>
</Global>
<!-- If no item type mappings are defined within ItemTypes or if storages on a lower level do not exist then the storage defined by defaultStorageId attribute will be used.
If storage defined by defaultStorageId does not exist then exception will be thrown. -->
<ItemTypes cached="true" defaultStorageId="defaultdb">
<Item typeMapping="Query" storageId="defaultdb"/>
<Publication Id="157" cached="false" defaultStorageId="defaultdb">
<Item cached="false" storageId="defaultdb" typeMapping="Page"/>
<Item cached="false" storageId="defaultdb" typeMapping="Binary"/>
</Publication>
</ItemTypes>
<!-- Specifies the location of the license file. -->
<License Location="D:/SDL/license/cd_licenses.xml"/>
</Configuration>
App setting Entry :
<!-- Basic DD4T Configuration Settings-->
<add key="DD4T.ComponentPresentationController" value="Component" />
<add key="DD4T.ComponentPresentationAction" value="ComponentPresentation" />
<add key="DD4T.PublicationId" value="157" />
<add key="DD4T.ProviderVersion" value="SDLWeb85" />
<add key="DD4T.DefaultPage" value="index.html" />
Global.ascx.cs:
public class MvcApplication : System.Web.HttpApplication
{
ILifetimeScope BuildContainer()
{
var builder = new ContainerBuilder();
builder.RegisterControllers(typeof(MvcApplication).Assembly);
builder.UseDD4T();
return builder.Build();
}
protected void Application_Start()
{
var builder = BuildContainer();
DependencyResolver.SetResolver(new AutofacDependencyResolver(builder));
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
Page Controller :
public class PageController : TridionControllerBase
{
public PageController(IPageFactory pageFactor,
IComponentPresentationFactory
componentPresentationFactory,
ILogger logger,
IDD4TConfiguration configuration) :
base(pageFactor, componentPresentationFactory, logger, configuration)
{ }
public override ActionResult Page(string url)
{
return base.Page(url);
}
}
Below are the framework/Templates I have used in my solution
- DD4T.MVC5
- DD4T.Providers.SDLWeb85
- DD4T.DI.Autofac
Here is the debug Log of my solution
In the log file I see the below text saying something is wrong with cd_Storage_confg file
2019-08-13 08:12:10,899 DEBUG ConfigurationRepositoryMonitor - Monitor is not initialized. Attempt:2
2019-08-13 08:12:10,899 INFO ConfigurationRepositoryMonitor - Configuration Repository Monitor setting up. Getting settings from 'cd_storage_conf.xml'
2019-08-13 08:12:10,899 DEBUG XMLConfigurationReaderImpl - Reading configuration from: 'cd_storage_conf.xml'
2019-08-13 08:12:10,899 DEBUG XMLConfigurationReaderImpl - Reading configuration from source: 'null'
2019-08-13 08:12:10,902 INFO ConfigurationRepositoryMonitorUtil - Configuration Repository not configured
Also I dont see any entry of Publication ID in the log. Am I passing the correct Key in the app settings for Publication details?
Can some one assist me here.
Update 1:
I can fetch the page meta data using the below code
var pageMetaFactory = new Tridion.ContentDelivery.Meta.PageMetaFactory(pubId);
var pageMeta = pageMetaFactory.GetMetaByUrl(pubId, pageId);
Also using the PageFactory I can fetch the Page content and Page Object . But the base.Page(pageuri) is always throwing exception saying "Page Cannot be found". I am using DD4T.MVC (version 2.2.6.0).
Also in the view when I am trying to use DD4T Html I am getting the below warning and at run time it fails to execute.