Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

WebApi with various parameters, one of them is a list

$
0
0

Hi Friends,

I'm developing a webapi application on .Net Core (Target Framework netcoreapp2.0). I've got a question about how work with parameters. The method to which the app will route must recieve two parameters. One of them must be a string with an alphanumeric identifier, and the other must be a list of strings. I have read that I can use [FromUri] parameter attribute and concat the parameters on the URL. I have read that on this link 

But I think that it seems unclean solution... ¿Do you know another ways to make that?

The example code on the link is the following:

publicIEnumerable<string>Get([FromUri]List<string> str){returnnewstring[]{"value1","value2"};}
http://localhost:59511/api/Values?str[]="abc"&str[]="xyz"

Perhaps it's only my impression, and really it's an elegant way.

Thanks a lot,
Regards


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>