Get values through get method parameters

Asked

Viewed 566 times

2

I have a action that sends by parameters the codCliente:

//master/CadastrarEndereco?codigoCliente=1011

How do I get that value codigoClientein my controller so I can persist the value in the BD?

1 answer

3

In his method CadastrarEndereco you can declare the parameter codigoCliente as follows and use it.

public ActionResult CadastrarEndereco(int codigoCliente){
    // codigoCliente preenchido aqui dentro
}

You can also access the object Request to obtain the sent parameters:

var codigoCliente = Request.QueryString["codigoCliente"];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.