Due to an irritatingly structured HTML design, I need to (in my 2011 SP1 DD4T .NET web application) be able to access certain Component Presentations on a page from within a Component view, to embed one CP within another.

I cannot use the ViewBag to pass the current IPage object around, as the CPs are rendered in a sub action, and the ViewBag is not shared across different actions.

I was poking around and saw I could probably make a custom ComponentPresentationRenderer and ComponentController which enable me to pass the page as a parameter to the sub action, but before I do this, is there a way to do this without this level of customization?

  • 4
    The ComponentPresentation has a Page property, which should give access to the entire page. Isn't that working for you?
    – Quirijn
    Jun 13, 2013 at 11:01
  • DOH! Thanks Q. I knew there had to be a simple answer...
    – Will Price
    Jun 13, 2013 at 15:20
  • I posted it as an answer now so it can be approved for future reference.
    – Quirijn
    Jun 14, 2013 at 9:31

2 Answers 2


The ComponentPresentation has a Page property, which gives access to the entire page.


Edit: see Quirijn's answer for this situation but I'm going to leave the below approach a for different situation.

One way I've achieved this (not in exactly the same situation - this was to find settings for a form after a POST and this is a little hacky) is to use the current url to look up the page from DD4T's PageFactory, since this is how DD4T found the page it's pretty reliable and the IPage object should be cached. I was using the Referrer but it should work just as well with the current Url.

Here's our code:

string url = UriHelper.ParseUrl(Request.UrlReferrer.AbsolutePath);
var page = PageFactory.FindPage(url);

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.