Copied to clipboard

Flag this post as spam?

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

  • Viktor Ekholm 8 posts 98 karma points
    Feb 28, 2018 @ 14:30
    Viktor Ekholm

    Non-Umbraco-based controller: Cannot bind source type...


    I'm trying to implement a non-Umbraco-based controller in an Umbraco project. The reason for it to not inherit from an Umbraco controller is that it's not dependent on any content within Umbraco.

    I have this controller:

    public class SearchController : System.Web.Mvc.Controller
        public ActionResult Index(string query)
            SearchViewModel viewModel = Search(query);
            return View(viewModel);

    I also have a rule set up so that I actually hit my action method when navigating to /Search?query=foo+bar.

    My view (~/Views/Search/Index.cshtml) defines that SearchViewModel should be model, but still I get the following exception:

    Cannot bind source type MyNamespace.SearchViewModel to model type Umbraco.Web.Models.RenderModel.

    Does my model really need to inherit from RenderModel for this to work?

    Thanks. /Viktor

  • Streety 358 posts 568 karma points
    Feb 28, 2018 @ 19:54

    What is the problem with inheriting from Umbraco.Web.Mvc.SurfaceController? I would use this just to handle the routing:

Please Sign in or register to post replies

Write your reply to: