Use the Parametter of a method in a controller | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

11th Aug 2017, 12:04 AM
Attitude
Attitude - avatar
2 Answers
0
Try using: nomOperation.Equals("addition",StringComparison.Ordinal); instead of: nomOperation == "addition" same for "soustraction"
11th Aug 2017, 12:23 AM
ChaoticDawg
ChaoticDawg - avatar
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.
11th Aug 2017, 2:18 AM
Attitude
Attitude - avatar