#100 Query Parameters

Woohoo!!!  Tip #100.  I cannot believe we made it this far.  If you have a tip, please share and maybe we can get to 200.

I love using query parameters because I can have the user customize a certain route and have all the customization be part of the URL which makes it easier to share and bookmark.

For an example the url https://www.hirejs.com/app/jobs?isContract=true&isRemote=true has 2 query parameters that filter jobs where isContract and isRemote are true.

The code is pretty straightforward, in my controller, I simply added:

That’s pretty much it, then you can bind these properties to inputs and they will change the url as their values are changed.  In this case they are bound to a toggle (checkbox) and every time the user toggles it, it changes the URL.

Here is a demo GIF, watch how the URL changes as I click around:


Published by

Emad Ibrahim

Author of asp .net MVC & TDD, entrepreneur, passionate technologist, programmer and productivity nut. more at http://t.co/oSJXPvzu