views:

117

answers:

1

I have been looking around the site a bit, but I didn't find any replies on how to do it the way I want.

What I want is an URL like this:

www.example.com/Projects/"querystring1 - text only"/"querystring2 - 4 digits only"/

to show the page with this URL:

www.example.com/Projects.aspx?Region=querystring1&Zip=querystring2

What I have been trying is the following:

<rewrite url="~/Leje-og-udlejning-arbejdskraft/(.+)/(.+)" to="~/Workers.aspx?Region=$1&amp;zip=$2"/>

But it just takes both of them as one querysting and put them in the Region-querystring.

A: 

I'd need to see the rest of your rewrite rules to be sure, but if you have multiple rewrites (i.e. to handle situations where users only specify one of the two query strings) neglecting to add processing="stop" at the end will cause one rule to override the other.

For example, I use the following setup in my web.config file:

<rewriter>
    <rewrite url="~/(.+)/(.+)" to="~/Default.aspx?ref=$1&amp;page=$2" processing="stop"/>
    <rewrite url="~/(.+)" to="~/Default.aspx?ref=$1" processing="stop"/>
</rewriter>

This will first check to see if 2 query variables are present. If they are, it rewrites them appropriately and stops processing other rules. This is the biggie. Without processing="stop" at the end, I end up passing both as the ref query string. This might be the conflict you're running in to.

EAMann
Andreas Strandfelt
Yes, that's exactly how I do it. That way you don't lose the extra query variables if they're there, but if they aren't it will automatically move to the next condition in your list.
EAMann