Copied to clipboard

Flag this post as spam?

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


  • Jacob Buus 18 posts 38 karma points
    Jan 04, 2013 @ 23:02
    Jacob Buus
    0

    Routing problem with MVC SurfaceController

    I've just started using Umbraco 4.11 and love the idea of using MVC with Umbraco - however I've gotten stuck with a particular problem that probably has a really simple solution - so I hope you guys can help me out :)

    I've create a custom SurfaceController - like so : 

    [PluginController("Contact")]
        public class ContactSurfaceController : SurfaceController
        {
            [ChildActionOnly]
            public ActionResult Index()
            {
                var model = new ContactViewModel();
                model.Text = "DEMO DEMO";
                return PartialView(model);
            }
        }

    The Index action-method makes use of a simple ViewModel that just contains a Text-property - simple stuff. 

    I then create my View - I wan't to have this placed in Views/Contact/Index.cshtml - hence the PluginController-attribute (as I've understood the usage of this). 

    My Index-view is as simple as it gets: 

    @model ContactViewModel
    
    <strong>@Model.Text</strong>

    On my content page I then try to render this by calling: 

    @Html.Action("Index", "Contact")

    But I get a runtime exception stating that :

    No route in the route table matches the supplied values.

    I Can't seem to figure out how to get on from here - so please please help me! :)

    Note that I've also tried: 

    @Html.Action("Index", "SurfaceContact")

    with the same result :(

  • Jacob Buus 18 posts 38 karma points
    Jan 05, 2013 @ 01:35
    Jacob Buus
    0

    I think I finally caught a break. 

    I skipped the PluginController and renamed my class to ContactController - now all the routes are working great with my Views placed in ~/Views/Contact.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies