mardi 5 mai 2015

Can't send parameters through POST on asp.net vNext app. (beta 3) (MV6, mono, EF7, OSX)

I hope someone can help me with this... I'm working on osx on a new small project and "getting to know" the new vNext with MV6 and Entity Framework 7, with mono, kestrel, and using sublime text for the coding... I have a very simple form:

<div class="login-form-outer">
    @using (Html.BeginForm("Login2", "Account", null, FormMethod.Post, new { @class = "form-horizontal", role = "form", @autocomplete="off" }))
    {
        @Html.AntiForgeryToken()
        <h4>Use a Local Account to log in.</h4>
        <hr>
        @Html.ValidationSummary(true)
        <div class="form-group">
            @Html.LabelFor(m => m.Name, new { @class = "col-md-2 control-label" })
            <div class="col-md-10">
                @Html.TextBoxFor(m => m.Name, new { @class = "form-control" })
                @Html.ValidationMessageFor(m => m.Name)
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Log in" class="btn btn-default" />
            </div>
        </div>
    } </div>
</div>

The form submits, the action "Login2" gets called, but the parameter never reaches the action... This is the action BTW.

[HttpPost]
[AllowAnonymous]
public IActionResult Login2([FromBody] string Name)
{   
    Console.WriteLine(Name);
    Console.WriteLine("Login2");
    return RedirectToAction("Index", "Home");
}

The only thing the console shows is "Login2", and the redirection also works.

The thing is... I have a virtual machine running a SQL Server database... I installed visual studio 2015 there, and executed the exact same project (shared folder) using WEB, KESTREL, and IIS, and they all worked! The parameter gets printed in the console... So I don't really know where the problem is... is it mono? is it kestrel on OSX?... please help!

I usually work with Rails and Laravel, I'm a noob here...

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire