Click to See Complete Forum and Search --> : Dynamic Url Routing


vouzamo
01-14-2011, 04:05 PM
How can I use the following url structure:

/{category_level1}/{category_level2}/{category_level3}/{category_level_n}

Where the structure is based on navigating down a hierarchy stored in a database and a user can remove a category level from the path to move back up the hierarchy.

I want to use this structure for an eCommerce site with the following example url:

/electrical/televisions/sony+bravia+40+inch+1080p/

Where removing /sony+bravia+40+inch+1080p/ would call a controller and action for listing electrical/televisions.

Not sure whether to use MVC2 Routing, Url rewriting etc.

svidgen
01-14-2011, 05:11 PM
Sounds like URL rewriting would be best. It should be fairly easy to rewrite something like ...

/nav/a/b/c/ -> /nav.aspx?location=a/b/c

So, if you're using .NET's interface, you can either use the "User friendly URL's" wizard, or manually set up a rule with the Match URL -> Pattern [using regular expressions] like ...

^nav/([^/]+)/?$

And an Action -> Rewrite -> Rewrite URL like ...

nav.aspx?location={R:1}

Then have nav.aspx break the location GET variable apart on the slashes and process accordingly.

vouzamo
01-17-2011, 02:53 AM
Thanks for the reply.

Just wondered how I can locate a specific url from non-specific data e.g. gucci/guilty/30ml-perfume-gift-set

Do I need to include a unique id somewhere or is there something else I can do to use this non-specific data to look up the unique id.

I would prefer to use MVC2 framework. Can I use URL rewriting with MVC2 to call a controller and an action with some parameters?

Kind regards,

John Askew

mmrcela
01-19-2011, 02:46 PM
Hi Vouzamo and Svidgen,
I am looking for a Software Developer in Illinois for a full time position at our company. Do either of you guys know of anyone looking for a company change in Illinois? I would appreciate any leads, thank you.