This blog post explains how the Sitecore ASP.NET web Content Management System (CMS) processes placeholders. For more information about using MVC with Sitecore, Posts about Using MVC with the Sitecore ASP.NET CMS.
Processing placeholders in MVC (Razor) views is not much different than processing placeholders in layouts and sublayouts, but with a few key differences:
To render a placeholder in an MVC view, you can pass the placeholder key to the Placeholder() method in the Sitecore.Mvc.Helpers.SitecoreHelper object returned by calling the Sitecore() method of the System.Web.Mvc.HtmlHelper class exposed by the Html property of the System.Web.Mvc.WebViewPage class from which the view inherits (or the System.Web.Mvc.WebViewPage<TModel> class for strongly-typed views). Put another way, to render the placeholder with key "body", put this in your view:
To render the contents of a placeholder, Sitecore invokes the mvc.renderPlaceholder pipeline defined in the /App_Config/Include/Sitecore.Mvc.config file. By default, the mvc.renderPlaceholder pipeline consists of the following processors:
You might notice that there is no ExitPlaceHolderContext processor in the mvc.renderPlaceholder pipeline. The reason is that the EnterPlaceHolderContext processor adds the PlaceHolderContext object it creates to a Disposables property of the Disposables collection property of the of the Sitecore.Mvc.Pipelines.Response.RenderPlaceHolder.RenderPlaceHolderArgs argument passed through the pipeline, which inherits from the Sitecore.Mvc.Pipelines.MvcPipelineArgs class used for Sitecore MVC pipelines. The MvcPipelineArgs class implements the System.IDisposable interface and in its Dispose() method, which calls the Dispose methods in any disposable objects in the Disposables collection.
As promised, some information about the mvc.renderRendering pipeline: www.sitecore.net/.../MVC-Renderings-and-Renderers-in-the-Sitecore-ASPNET-CMS.aspx
Has the @Html.Sitecore().PlaceHolder("body") changed to @Html.Sitecore().Placeholder("body")? I also find that the standard <sc> tags no longer work. I'm sure you guys already knew this but I don't see any references to that fact.
Yes, engineering changed PlaceHolder to Placeholder. There is some internal discussion about changing this to PlaceHolder in other places, but I prefer the lowercase h. Placeholder is a word in English but Microsoft sometimes adds a space and/or capitalizes the H. If you mean tags such as <sc:text>, those are Web controls (and XSL extension controls) that won't work in MVC views. In MVC, you have to use alternatives such as @Html.Sitecore().Field().