Last post Nov 23, 2016 08:42 AM by 我_爱编程
Oct 30, 2016 07:25 AM|aa_champ|LINK
How can I have my controller actions get triggered by parameter names.
public IActionResult Test(int a1) ... http://test.com?a1=3
public IActionResult Test(string s1, string s2) http://test.com?s1=3&s2=10
I want the actions to get triggered by the matching parameter name.
This is how the old web api used to work but since I am doing this with .net core mvc controller I am not able to produce the same results.
Appreciate in advance.
Oct 30, 2016 10:36 AM|mgebhard|LINK
Use default parameters and check for empty.
public IActionResult Test(string s1 = string.Empty, string s2 = string.Empty)
Or if you want to overload the action results, then see the following. Be careful, make sure that you understand routing so that you don't paint yourself in a corner.
Nov 22, 2016 10:35 AM|nayan_godhani|LINK
Please use following code.
public IActionResult Test(string s1=null, string s2=null)
this method calls also when pass no parameter or pass single s1 parameter and pass both parameter
Nov 23, 2016 08:42 AM|我_爱编程|LINK
Please use the alternative solution to add tags to the method.Such as code below: