N
N
Nikita072021-04-19 12:16:53
ASP.NET
Nikita07, 2021-04-19 12:16:53

How to call the controller parvily, passing an array as a parameter?

Hello everyone, there is such a controller:

607d4a2daf2d4805888050.png

The question is, how to access the GetParam action by passing an array to it?
I tried this method, but it ended with an error

607d4a6c4ba51269494338.png

PS If you delete the first action, then everything works as it should
PSS You cannot use the [Route] attribute

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2021-04-19
@Nikita07

Emnip, when using convention-based routing, the Get prefix from the method name is discarded.
So the path should look like this:
http://localhost:5000/api/Rtb/Param?ids=1&ids=2

PS If you delete the first action, then everything works as it should

Apparently a collision, because you have both of them marked with HttpGet - so both will be on the same path. And FromQuery parameters are optional - so it cannot select one of them (which is most likely written in the log)
Remove the first action and leave only the option with the parameter

C
cicatrix, 2021-04-19
@cicatrix

Try

http://localhost:5000/api/Rtb/GetParam?ids=68&ids=65

But in general, to transfer arrays to the controller with GET, in my opinion, is a perversion.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question