2

I'm working on a search page with a lot of filters on it and my client is allergic to the query string.

As I add more filters, I keep having to write more urls / redirect rules for each one, and it's becoming exponential

Examples:

 <rule name="Case_TypeFilter_And_Filter_And_Search" stopProcessing="true">
        <match url="^cases/type/([a-zA-Z]+)/filter/(.+)/search/(.+)/cat/([a-zA-Z]+)/$"/>
        <action type="Rewrite" url="cases/search.aspx?claimtype={R:1}&amp;filter={R:2}&amp;search={R:3}&amp;cat={R:4}"/>
 </rule>

 <rule name="Case_ClientFilter_Type" stopProcessing="false">
      <match url="^cases/([0-9]+)/type/([a-zA-Z]+)/?$"/>
      <action type="Rewrite" url="cases/search.aspx?client={R:1}&amp;type={R:2}"/>
 </rule>

Is there any generic rule I use to redirect the keys and values from the url into the query string?

Convert this: http://foo.bar/cases/cat/2/search/hello/type/5

To this: http://foo.bar/cases/search.aspx?cat=2&search=hello&type=5

As well as

Convert this: http://foo.bar/cases/type/8/client/356/cat/10/search/world

To this http://foo.bar/cases/search.aspx?type=8&client=356&cat=10&search=world

Callum
  • 869
  • 5
  • 23

0 Answers0