Copied to clipboard

Flag this post as spam?

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


  • Jason 7 posts 68 karma points
    Oct 27, 2014 @ 23:17
    Jason
    0

    No route error when using SurfaceController in Umbraco 7.1.8

    Hi there,

    I am trying to figure out how to get a SurfaceController working as in these screencasts on Umbraco.tv: Surface Controllers. The problem is that when I try to navigate to the Contact Us page, I get a "No route in the route table matches the supplied values." error.

    My surface controller:

    namespace UmbracoSurface2.Controllers
    {
        public class ContactFormSurfaceController : SurfaceController
        {
            public ActionResult Index()
            {
                return PartialView("ContactForm", new ContactFormViewModel());
            }
        }
    }

    My ContactForm partial:

    <form> <div> @Html.TextBoxFor(m => m.Name) @Html.TextBoxFor(m => m.Email) </div> <div> @Html.TextAreaFor(m => m.Message, new { rows="5" }) </div> <div> <button id="contact-submit" type="submit">Submit</button> </div> </form>

    and my template:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "Master.cshtml";
    }
    @Html.Action("Index", "ContactFormController")

    The one big difference between mine and the screencasts is that I'm using Visual Studio 2013 so the ASP.NET Website template has a newer version of MVC which I had to remove to get the UmbracoCms NuGet package to install. I also tried it without adding MVC to the project at the beginning.

    Any help/suggestions would be appreciated,

    Jason

  • Dan Lister 416 posts 1974 karma points c-trib
    Oct 28, 2014 @ 11:25
    Dan Lister
    101

    Hi Jason,

    I might be wrong but shouldn't your template reference the controller like the below instead of 'ContactFormController'?

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

    Thanks, Dan.

  • Jason 7 posts 68 karma points
    Oct 28, 2014 @ 15:07
    Jason
    1

    Wow, I can't believe I missed that. You're exactly right Dan! I must have been tired yesterday.

    Thanks,

    Jason

Please Sign in or register to post replies

Write your reply to:

Draft