locked
How to intercept server side the search term from a quick search box? RRS feed

  • Question

  • It's pretty simple to intercept server side the query params of a custom query in the Query_Executed (or  _Executing) method.

    partial void Query_Executed(QueryExecutedDescriptor queryDescriptor)
            {
        //        queryDescriptor.Parameters gives access to the query parameters
            }

    Nice, but how can I intercept SERVER side the search terms which are filled in in a quick search box? 


    paul van bladel


    Saturday, May 25, 2013 11:21 AM

Answers

  • Hi Paul,

    I had a play around with it and it seems you can detect the search terms from the query string:

    using System.Web;

    var qString = HttpContext.Current.Request.QueryString;

    var search = qString["_search"];

    The query parameter key is "_search" and this looks to be good in the *_Executing and *_Executed events.

    Having detected the search term it does not allow you to change it so it needs more playing around and need to debug a few other query / search scenarios.

    Cheers

    Dave


    Dave Baker | Xpert360 blog | twitter : @xpert360 | Xpert360 website Opinions are my own. For better forums, please mark as helpful/answer, if it helps/solves your problem.


    Sunday, June 2, 2013 2:03 PM

All replies

  • Paul,

    This is not exactly what you are asking for but check this post where Justin shows how to access the default search box.  I'm not sure there is any execution going on server side by default.  You may need to grab the parameters client side and send them to the server yourself.

    Sunday, May 26, 2013 4:58 AM
  • Hi,

    Thanks for that, but I'm aware of that technique. I need a pure server side solution for intercepting the query string from the silverlight quick search box 


    paul van bladel

    Sunday, May 26, 2013 7:49 AM
  • Good question, Paul.

    FYI:  I'd still like to know how to also save and reuse the entire "query" var.


    Garth Henderson - Vanguard Business Technology

    Tuesday, May 28, 2013 1:28 PM
  • No one???

    paul van bladel

    Sunday, June 2, 2013 10:21 AM
  • Hi Paul,

    I had a play around with it and it seems you can detect the search terms from the query string:

    using System.Web;

    var qString = HttpContext.Current.Request.QueryString;

    var search = qString["_search"];

    The query parameter key is "_search" and this looks to be good in the *_Executing and *_Executed events.

    Having detected the search term it does not allow you to change it so it needs more playing around and need to debug a few other query / search scenarios.

    Cheers

    Dave


    Dave Baker | Xpert360 blog | twitter : @xpert360 | Xpert360 website Opinions are my own. For better forums, please mark as helpful/answer, if it helps/solves your problem.


    Sunday, June 2, 2013 2:03 PM
  • Hi Dave

    Of course ! The good old querystring :)

    thanks for the help Dave.

    Cheers

    paul.


    paul van bladel

    Sunday, June 2, 2013 3:32 PM