ASP WebAPI General Optional List Parameter

I really struggle with that. I need a generic list parameter for my Get method, but it should be optional. I just did this:

public dynamic Get(List <long> ManufacturerIDs = null) 

Unfortunately, at runtime I get an error message:

The optional parameter 'ManufacturerIDs' is not supported by 'FormatterParameterBinding'.

How to get a general list as an optional parameter here?

+42
asp.net-mvc asp.net-web-api
Mar 26 '13 at 15:12
source share
1 answer

What is the point of using an optional parameter? List<T> is a reference type, and if the client does not specify a value, it will simply be null:

 public HttpResponseMessage Get(List<long> manufacturerIDs) { ... } 
+71
Mar 26 '13 at 15:30
source share



All Articles