Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Sep 13, 2014 @ 10:17
    Nicholas Westby
    0

    Return Model From SurfaceController?

    Why isn't there an overload of Umbraco.Web.Mvc.SurfaceController.CurrentUmbracoPage that accepts a model to propagate to the view?

    Note that I've found multiple workarounds, but I wonder why this seemingly obvious approach doesn't seem to be supported like it is in normal MVC (namely, the overload of System.Web.Mvc.Controller.View that accepts a model instance).

    Note that my favorite workaround is this, though I don't much like hardcoding view paths in action methods (especially since the user can potentially change the template in the CMS):

    public class SomePageSurfaceController : SurfaceController
    {
        [HttpPost]
        public ActionResult SomeMethod()
        {
            var model = SomeNamespace.SomeClass.SomeLogic(CurrentPage);
            return View("~/Views/SomeView.cshtml", model);
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft