Copied to clipboard

Flag this post as spam?

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


  • Peter S 169 posts 587 karma points
    Apr 10, 2014 @ 09:52
    Peter S
    0

    Hijacked route post action not firing

    Hi,

    Any input as to why this HttpPost is not firing? There is a postback taking place when send is pressed buyt the when putting a break point in the HttpPost it's never fired.

    Here's a snippet of my code. I had to put spaces in the input tag for it not to render the actual button.

    @inherits UmbracoViewPage
    @{
        Layout = "Layout.cshtml";
    }
    @using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.TextAreaFor(m => m.Message)
            < i n p u t type="submit" value="Send" />
    @Html.ValidationMessageFor(m => m.Message) </div>
    }

    public ActionResult Index(ManageMessageId? smess)
    {
    var errorModel = new ErrorModel();
    ...
    return CurrentTemplate(errorModel);
    }
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Index(ErrorModel model)
    {
    if (ModelState.IsValid)
    {
    ...
    }

    return View();
    }
  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Apr 10, 2014 @ 12:12
    Jeroen Breuer
    100

    Hello,

    What kind of controller are you using? In Umbraco a HttpPost to a controller only works with a SurfaceController by default. You can also use a SurfaceController for route hijacking and post back to that like I did in the Hybrid Framework.

    Jeroen

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Apr 10, 2014 @ 12:14
    Jeroen Breuer
    0

    This documentation might also help: http://our.umbraco.org/documentation/reference/Templating/Mvc/forms

    Jeroen

  • Peter S 169 posts 587 karma points
    Apr 10, 2014 @ 15:01
    Peter S
    0

    Thanks for your reply! I had it inherit from RenderMvcModel so I see the mistake. However, it seemed like a bit too much work so I just renamed the actions to the same name as the template. All good! :)

  • 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