Site.WithServices.cshtml and @RenderBody()

Oct 11, 2012 at 6:36 PM

Is it by design that the new Site.WithServices.cshtml does not call @RenderBody().

I have custom views, loaded off custom controllers, that uses Site.WithServices.cshtml as the layout, but they fail because it doesn't call @RenderBody().

I am not all that up to speed with MVC 4 yet. Is there something I am missing?

Coordinator
Oct 11, 2012 at 7:03 PM

"Is it by design that the new Site.WithServices.cshtml does not call @RenderBody()."

Not specifically.  As you know -  we currently test only against the .aspx  -  and provide the translations into .cshtml as a not-thoroughly-tested option.  (That position could change in the future).

I did the translations largely using an automated tool and briefly tried them out to ensure that they run.  So I have no idea of the significance of why it is or isn't calling @RenderBody.  I suggest you just experiment with editing them to the way you prefer (using the .aspx equivalents as a guide, as well as the generic .cshtml files from a standard MVC4 project) and report back on success or otherwise.  If your versions work, and don't alter the generic Naked Objects UI in any way, I'd be glad to incorporate your versions into the source if you would like.

Oct 11, 2012 at 10:45 PM

In your old Site.WithServices.cshtml you had:

	<div id="main">
		@(RenderBody ())
	</div>

In the new one you have:

 

        <section class="content-wrapper main-content clear-fix">
            @RenderSection("MainContent", required: false)
        </section>

When I modify it as follows, it fixes my problem and all generic NO MVC behavior still works.
        <section class="content-wrapper main-content clear-fix">
            @RenderSection("MainContent", required: false)
            @(RenderBody ())
        </section>


I haven't looked into this in depth, but did notice that you also don't have @RenderBody () in the new Site.WithServices.Master.