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".
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.
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.
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:
I have placed the DLL in the Umbraco.Web.UI\bin directory
I have created the following directories:
Within each of these directories, I have added the follwing view file: MyNameForm.cshtml
I then went into Umbraco and created a new Template/Document Type.
The Template is called TestMVC,and the code looks like the following:
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:
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.
If you try
@{ Html.RenderAction("RenderMyName", "MySurface"); }instead, does this cause the same error?
Thank you for the reply. Unfortunately, it does cause the same error.
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.
David, thank you. I owe you lunch if you are ever in northern Utah.
is working on a reply...
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.