Say I have an ASP.Net MVC site with products and categories, and I want these urls...
Products:
- Fruitshop.com/super-tasty-apple
- Fruitshop.com/squishy-orange
- Fruitshop.com/worm-infested-apple
- Fruitshop.com/megaorange
Categories:
- Fruitshop.com/apples
- Fruitshop.com/oranges
For each product/category in the database, I save the slug (or whatever you call it), like "super-delicous-apple" or "apples".
There is no pattern or regular expression(that I can see, anyway), that allow me to determine just by looking at the url, if it is a product or a category. I need to look in the database to know.
What would be a good way to approach this?
- At application startup, register the route of every single product and category
- Create some code that handles the requests, and look up the slug in the database
- ??
Nevermind caching, refreshing routing-table etc for now. :)
Feel free to edit my question title, if you feel there is a more appropriate title for this question - this was the best I could come up with.