using System.Web.Mvc; using Umbraco.Web.Models; namespace Umbraco.Web.Mvc { public class RenderModelBinder : IModelBinder { /// /// Binds the model to a value by using the specified controller context and binding context. /// /// /// The bound value. /// /// The controller context.The binding context. public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var requestMatchesType = typeof(RenderModel) == bindingContext.ModelType; if (requestMatchesType) { //get the model from the route data if (!controllerContext.RouteData.DataTokens.ContainsKey("umbraco")) return null; var model = controllerContext.RouteData.DataTokens["umbraco"] as RenderModel; return model; } return null; } } }