MVC error 404 POST method

0

This is my controller :

[HttpPost]
public ActionResult TestePost(int id1)
{
    ViewData["Teste"] = "O método POST funcionou, você digitou: " + id;

    return View("Index");
}

   [HttpGet]
    public ActionResult TesteGet(int id)
    {
        ViewData["Teste"] = "O método GET funcionou, você digitou: " + id;

        return View("Index");
    }

Below my view :

@using (Html.BeginForm("TesteGet", "Home", FormMethod.Get))
{
    <fieldset>
        <legend>Form tipo GET</legend>

        <input type="text" name="id" id="idGet" value="" />
        <input type="submit" name="enviar" value="enviar Get" placeholder="apenas numeros" />

    </fieldset>

}
<br/>
<hr/>
<br/>
@using (Html.BeginForm("TestePost", "Home", FormMethod.Post))
{   
    <fieldset>
        <legend>Form tipo POST</legend>

        <input type="text" name="id1" id="idPost" value="" />
        <input type="submit" name="enviar" value="enviar Post" placeholder="apenas numeros"/>

    </fieldset>


}

<h1>@ViewData["Teste"]</h1>

My problem: Method GET works perfectly, post method does not work. Highlight: When is localhost works perfectly POST and GET when I put in Locaweb gives this error.

    
asked by anonymous 01.06.2016 / 04:06

1 answer

0

Your second form has IDs that are different from those expected by Controller .

@using (Html.BeginForm("TestePost", "Home", FormMethod.Post))
{   
    <fieldset>
        <legend>Form tipo POST</legend>

        <input type="text" name="id1" id="id1" value="" /> <!-- ID1 e não IDPOST -->
        <input type="submit" name="enviar" value="enviar Post" placeholder="apenas numeros"/>    
    </fieldset>    
}
    
01.06.2016 / 10:12