Copied to clipboard

Flag this post as spam?

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

  • Aki 43 posts 214 karma points
    Jan 10, 2016 @ 01:48

    Controller routes and Post request from FormPost gives an error

    Hi Im trying to make a Email Verification on my webpage for a newsletter ..

    Im Using a Route Tabel to Make it a Link in a email.

            controller = "Newsletter",
            action = "Verify",
            id = UrlParameter.Optional

    The Surface controller is controling the Partial view for the Newsletter form and a post including the Verifiy Url path

    public ActionResult RenderSubscriptionFormPartialView()
        return PartialView("Partials/Newsletter/SubscriptionForm", new MailinglistSubscriptionModel());
    // GET: Newsletter/Subscribe
    public ActionResult Subscribe(MailinglistSubscriptionModel model)
            return RedirectToCurrentUmbracoPage();
     // GET: Newsletter/Verify
    public ActionResult Verify(int contentId, string verificationHash)
        // Verification success
        return Redirect("/");

    The ting is the Subscribe ActionResult breakes when i make the Route in the route tabel

    and the same with Verify ...

    What am i doing wrong ? The error i get is this..

    Stack Trace:     
    [InvalidOperationException: Could not find a Surface controller route in the RouteTable for controller name Newsletter]
           Umbraco.Web.Mvc.RenderRouteHandler.HandlePostedValues(RequestContext requestContext, PostedDataProxyInfo postedInfo) +667
           Umbraco.Web.Mvc.RenderRouteHandler.GetHandlerForRoute(RequestContext requestContext, PublishedContentRequest publishedContentRequest) +69
           Umbraco.Web.Mvc.RenderRouteHandler.GetHttpHandler(RequestContext requestContext) +114
           System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +174
           Umbraco.Web.UmbracoModule.RewriteToUmbracoHandler(HttpContextBase context, PublishedContentRequest pcr) +163
           Umbraco.Web.UmbracoModule.ProcessRequest(HttpContextBase httpContext) +417
           Umbraco.Web.UmbracoModule.<Init>b__8(Object sender, EventArgs e) +80
           System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +200
           System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +70

    A possible solution is to seperate the Controller out in to 2 one for the default action and one for Route.....

  • Nicholas Westby 2045 posts 7032 karma points c-trib
    Jan 10, 2016 @ 05:11
    Nicholas Westby

    I don't see why you are trying to register a route for your surface controller. For one, surface controllers generate a route for you. Secondly, surface controllers use a mechanism other than the URL to perform routing.

    See here for information on the routing that does not require a particular URL:

    You can scroll up that page for information about the default routes Umbraco generates for surface controllers.

  • Aki 43 posts 214 karma points
    Jan 10, 2016 @ 17:51

    The main reason was to bunch together Functions in a controller that made sense to have together .

    The Web site Would be somthing like this..

    Newsletter SubscribeForm - A partial View with a Webform

    Newsletter Subscribe Post - the post to submit data to umbraco and Create a newsletter

    Newsletter Verify - The route from a site that Verifies the Registered email http://URL/Verify/Newsletter/{ID}/{VerificationCode}

    The address in then included in a email send to the User under post ...

  • Nicholas Westby 2045 posts 7032 karma points c-trib
    Jan 10, 2016 @ 20:31
    Nicholas Westby

    If you are going to define your own route rather than use the route automatically created by the surface controller, perhaps you should consider a RenderMvcController. See here:

    A RenderMvcController is similar to a surface controller, except you need to create your route for your RenderMvcController, which may be appropriate considering you are attempting to create your own route.

Please Sign in or register to post replies

Write your reply to: