Hijacked Umbraco HttpPost Doesn't Shoot

I hijacked a route in Umbraco 7.1, and for some reason my HttpPost doesn't fire when the submit button is pressed. Is there any information on why this is so? When sending a push, a postback occurs, but when setting a breakpoint in HttpPost, it never started.

Here is a snippet of my code, markup followed by a controller.

@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();
}
+4
source share
1 answer

Assuming you are using SurfaceControllers, you would like to create your form as follows. Note the change in the way the form is created and how the general and parametric parameters correspond to the surface controller:

@using (Html.BeginUmbracoForm<MyController>("Index"))
{
}

:

public class MyController : SurfaceController
{
    public ActionResult Index(ManageMessageId? smess)
    {
        var errorModel = new ErrorModel();
        ...
        return CurrentTemplate(errorModel);
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Index(ErrorModel model)
    {
        if (ModelState.IsValid)
        {
            ...
        }

        return View();
    }
}
+1

Source: https://habr.com/ru/post/1535887/


All Articles