Copied to clipboard

Flag this post as spam?

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


  • Ben Haynie 20 posts 50 karma points
    May 10, 2013 @ 02:29
    Ben Haynie
    0

    V6 Surface Controller Plugin - template error:No route in the route table matches the supplied values

    Any help here would be much appreciated.  I am using Umbraco v6.1.0 (Assembly version: 1.0.4877.26421), and am trying to create a Plug-in Surface Controller.  The thought is that we would create our own Surface Controller to connect to our backend Webservices and database and interact with the data through Umbraco. 

    When I try to reference this Surface Controller in a template, I get an error that "No route in the route table matches the supplied values"

    I have created a DLL called TestControllers
    It has the following class in it:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Web.Mvc;
    using Umbraco.Web.Mvc;

    namespace TestControllers
    {
    [PluginController("GovAP")]
    public class MySurfaceController : Umbraco.Web.Mvc.SurfaceController
    {
    public ActionResult Index()
    {
    return Content("hello world");
    }

    [ChildActionOnly]
    public ActionResult RenderMyName()
    {
    return PartialView("MyNameForm", new Models.TestViewModel());
    }
    }
    }
    namespace TestControllers.Models
    {
    public class TestViewModel
    {
    public string Name
    {
    get { return "My Name"; }
    set { }
    }
    }
    }

    I have placed the DLL in the Umbraco.Web.UI\bin directory

    I have created the following directories:

    App_Plugins\GovAP\Views\MySurface
    App_Plugins\GovAP\Views\Shared

    Within each of these directories, I have added the follwing view file: MyNameForm.cshtml

    @model TestControllers.Models.TestViewModel
    The name specified is:
    <br />
    <strong>@model.Name</strong>

    I then went into Umbraco and created a new Template/Document Type.

    The Template is called TestMVC,and the code looks like the following:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage

    Action: @Html.Action("RenderMyName", "MySurface")

    Next I created a page called Test which uses this template, and when I navigate to it (http://localhost:61638/test.aspx), I get the error:

    "No route in the route table matches the supplied values".

    I am able to go to http://localhost:61638/umbraco/GovAP/MySurface and when I do, I see the following:

    hello world

    which seems correct.

    However, how do I get the template to call the controller, and the controller to return the view MyNameForm without the error?  Any help would be appreciated.

    Thank you,

    Ben

    P.S. I am trying to make this a plug in because the ultimate goal is to package these controllers up and distribute them, update them in the future, etc.  I would utimately like people to be able to create their own views via Umbraco and Razor, and utilize our surface controllers as well.

  • Andreas Iseli 150 posts 427 karma points
    May 10, 2013 @ 07:39
    Andreas Iseli
    0

    If you try

    @{ Html.RenderAction("RenderMyName", "MySurface"); }

    instead, does this cause the same error?

  • Ben Haynie 20 posts 50 karma points
    May 10, 2013 @ 16:18
    Ben Haynie
    0

    Thank you for the reply.  Unfortunately, it does cause the same error. 

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    May 10, 2013 @ 18:05
    David Brendel
    0

    Hey i tried it and became the same error as you.

    Fixed it by using: @Html.Action("GetHello", "TestSurface", new { name = "David", area = "SurfaceTest" }). Where "SurfaceTest" is your plugin name you set for the controller. In your case "GovAP"

    Hopefully it will fix your problem as well.

    You have to use @inherits Umbraco.Web.Mvc.UmbracoViewPagein your view. If not you get another error.

  • Ben Haynie 20 posts 50 karma points
    May 10, 2013 @ 18:54
    Ben Haynie
    0

    David, thank you.  I owe you lunch if you are ever in northern Utah.

Please Sign in or register to post replies

Write your reply to:

Draft