0

I have a controller method like that:

 public async Task<IEnumerable<MyModel>> GetLinks(IList<string> links)
        {
        }

Is there anyway I can pass the params to that controller method form url like so:

<endpoint>/getginks?links=http://link1&?links=http://link2 etc?

but for some reason I cant even pass a single param <endpoint>/getginks?links=http://link1 In that case controller getting hit but links = null, I checked on debug.

is there anything I can do?

2 Answers 2

1

You need to add the array specification to the URL params, similar to if you were producing POST params from a view.

Try:

/getginks?links[0]=http://link1&links[1]=http://link2&links[2]=http://link3
Sign up to request clarification or add additional context in comments.

Comments

1

You need to encode your string and then pass it to your controller.

you can use ajax call, before submitting just encode it $.htmlEncode(links) with the use of jquery.html.encode.decode.js

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.