Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

best practice to use an object filter in search app? #3349


User avatar
0
fguo created

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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    fguo created

    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,

  • User Avatar
    0
    ismcagdas created
    Support Team

    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

    1. Move your method to a controller and mark it with HttpPost attribute.
    2. 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.