We noticed that when debugging our MVC5 DD4T application the page controller gets executed more than once. The same breakpoint is hit multiple times and all component presentations get rendered twice.

The markup returned is also funky... there are multiple doctype declarations and multiple and tags rendered.

I've scanned the code to see if something is calling the page controller multiple times - nothing. I've also checked my area registration and routes configs, and those are all in order.

What could be causing this?

1 Answer 1


The problem with multiple doctype declarations can be caused by some standard mvc view behaviour.

In your mvc project, you can define a _viewstart.cshtml file. In here, you specify the default mvc "master page" (called "layout page") to use. This layout page will be outputted around all of your views that don't specifiy a custom layout. you can specify a custom layout page per view by adding this piece of code on top of your view


you can also specify not to use a layout by putting this


Now, as all of your component cshtml views are usually in one subfolder, an easy fix for this is to add a new _viewstart.cshtml file in the root of the components view folder containing this piece of code

    Layout = null;

As a result, you can have your page views have a standard layout.cshtml masterpage, and all of your components have no master page.

  • Thanks Harald. This certainly solves the funky markup problem. Regarding the page controller being hit multiple times, it is not a related issue. We realized that there is some well-hidden javascript that makes second call to the same page - so it's a non-issue. I'm marking your answer as correct. Aug 4, 2014 at 15:23

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.