Pass Facing to Controller

1

I've been looking for a solution for several days but I have not found anything useful to me. The problem is this, I have a Conttroller that gets the data from the View , so far so good, but when I'm going to capture this data it only captures through the bank method (User table) but wanted it to also store the value of the id in an integer.

Public actionResult criar ( Usuario usuario, int id)
{
    //Faz o que tem que ser feito 
// Ele só pega o valor no usuario e no id da como nulll


}
    
asked by anonymous 07.06.2017 / 17:02

1 answer

1

No id your field is coming as null because in your view in the form there is no field like id, for this to work you can do as follows:

@Html.HiddenFor(model => model.Id)

Do this within BegginForm

@Html.BegginForm....

That your id value will arrive in the controller

    
07.06.2017 / 17:56