I have created a new local setup for a DD4T publication in MVC4/Tridion 2013 sp1. In the pagecontroller I am querying for the component and successfully passing it's tcmid using viewbag to my view. I am getting error in the view as shown below, though the argument has the correct component id which is already published in broker-
PS: Please ignore my hardcoding of id's as I'll configure it later
Controller -
var client = new CDS.ContentDeliveryService(new Uri("tridion2013server", UriKind.Absolute));
int publicationId = xx;
int componentTemplateId = xxxxx;
var componentPresentations = client.ComponentPresentations
.Where(u => u.PublicationId == publicationId && u.TemplateId == componentTemplateId)
.ToList();
try
{
foreach (var cp in componentPresentations)
{
if (cp.ComponentId.Equals(xxxxx))
{
ViewBag.headerCompId = cp.ComponentId.ToString();
return View();
}
}
}
View -
@{ Layout = "";
var lf = new LinkFactory();
var cf = new ComponentFactory();
lf.LinkProvider = new TridionLinkProvider();
var compId = "tcm:73-" + ViewBag.headerCompId;
var comp = cf.GetComponent(compId); **// error - System.ArgumentNullException: Value cannot be null. Parameter name: type**
}