开发者

Can I pass a querystring that translates to a List<int> on the server?

开发者 https://www.devze.com 2023-01-03 03:03 出处:网络
I\'m writing a Google Maps app that requests data from the server using jQuery\'s $.ajax() t开发者_JS百科o send the request to my ASP.Net MVC Contoller. This control expects a List for the amenity typ

I'm writing a Google Maps app that requests data from the server using jQuery's $.ajax() t开发者_JS百科o send the request to my ASP.Net MVC Contoller. This control expects a List for the amenity types. What should the querystring look like for this?

I've tried

http://localhost:9090/mapamenities?amenityTypes=1,5

http://localhost:9090/mapamenities?amenityTypes=[1,5]

with no luck.

The SearchRquest attribute I'm trying to bind to is

public List<int> AmenityTypes { get; set; }

Thanks Denis


Try ?amenityTypes=1&amenityTypes=5.


The default MVC model binder will handle primitive collections as per earl's answer. If you have any need to bind complex types take a look at this project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号