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)
    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**
  • Hi, could you explain the purpose of this code? It's a bit unclear what you're intending to achieve. It looks like you've got logic in your View which is not advised for MVC (and by extension DD4T). Jan 8, 2015 at 17:04
  • I have now separated the code - the c# code is in the controller and not in the view. Jan 8, 2015 at 17:16
  • Thanks that is a little clearer, what exactly are you trying to do though? It looks like you're trying to use a common component for the header on each page - is that correct? Jan 8, 2015 at 18:57
  • right, for header i m trying to get the it's comp id through odata and passing the id to view using viewbag Jan 8, 2015 at 19:14
  • If your Header is a DCP - you could request it from the broker via DD4T. It still looks like you have too much code in your view. I would not expect to see use of Component Factory in the View. That should happen in the Controller. Jan 9, 2015 at 13:22

1 Answer 1


I would advise against using both the Content Delivery Service AND DD4T to retrieve content from the broker database. Seeing as how you already know the component to retrieve why query the Content Delivery Service for it? And if you do want to query it is more efficient to do so via the Broker libraries then via the Content Delivery Service...

As for your specific problem: I've looked through all of the code and cannot find any code in DD4T that would throw the exception as you have stated; can you provide us with a stacktrace? I could not find any code that would throw the exception as you have mentioned...

Your Answer

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

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