I am studying the Documents/Developing-Step-By-Step-Angular. The GetPeopleInput class contains only one string type filter, and the Angular UI adds a string value as a parameter in url. In my application, the search criteria contain multiple filters like a complex object. For example:
criteriaObj: { filter1: string, filter2: date, filter3: [ {}, {} ] }
I wonder what is the best practice to handle such filter object in ASP.NET Zero projects? Do you have an example about it?
Thanks,
3 Answer(s)
-
0
Hi @fguo,
When you create a input class for your application service on the server side and refreshing angular service proxies with nswag, this should work without any extra work.
Have you tried it ?
Thanks.
-
0
It is amazing! It works on many cases as my test. :o
However, it is still adding filters into url string. As my test, if the filters' value is too long (e.g. 2500 characters), it responses with 404 error code. :(
In my application, the search criteria contain multiple filters with complex objects. It is easy to over the url length limit. Do you have another way to pass filter object? :?:
Thanks,
-
0
Hi,
App service methods start with "Get" are called with HTTP Get request by convention. Because of that, all parameters are added to query string.
For your case you can either
- Move your method to a controller and mark it with HttpPost attribute.
- Normally we don't reference web "Microsofty.AspNetCore.Mvc.Core" to app layer but you can add it and add HttpPost attribute to your app service method.
Thanks.