Get values through get method parameters

2

I have action that sends by parameters the codCliente :

//master/CadastrarEndereco?codigoCliente=1011
How do I get this value codigoCliente in my controller so that I can persist the value in the DB?

    
asked by anonymous 18.11.2014 / 20:34

1 answer

3

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

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

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

var codigoCliente = Request.QueryString["codigoCliente"];
    
18.11.2014 / 20:39