0
Use the Parametter of a method in a controller
Hello Everybody, In a methode of my controller, i give a string parameter: public ActionResult ToutesLesOperations(string nomOperation). Depending on the value of this parameter i want to show the result of my operation. Here is my code: https://code.sololearn.com/cv7fkEkfvmbv/# Thank you for your help.
2 Respostas
0
Try using:
nomOperation.Equals("addition",StringComparison.Ordinal);
instead of:
nomOperation == "addition"
same for "soustraction"
0
Yeah, i did it.
I also modify the route_config.
In the and of the url, i puted the name of the variable that i defined in the parameter of the controller.
routes.MapRoute(
name: "Mathematique",
url: "{controller}/{action}/{nomOperation}",
defaults: new {controller ="Operation", action="Index", nomOperation="addition"}
);
Here is the code: https://code.sololearn.com/cCuCpXIzG31F/#
Thank you for your help.