I have an MVC 3 application where I want dynamic Urls which do not contain a controller or key name. A good example of this would be if I had a blog, and users add in new posts.
Say a user creates a post called
My Blog Post
I have a method that creates a url SLUG and stores it in the database with the entry, so I want the Url to be
/my-blog-post
This has no controller or key name in the url now? How do I achieve this with MVC routing? Currently I'm doing it by matching the Url with an ID like /my-blog-post_1234 and using that ID as the DB lookup key using fluent nhibernate but I'm a little lost once I remove the ID?
As I can still get the string/slug, but that means I now have to do a SQL lookup based on the string 'my-blog-post'? I have read this is not efficient and could compromise speed, and some of these titles could be pretty long.
I've heard people saying things about custom route tables? Would this help me or not? I suppose the main thing is getting the data from the database in the quickest most efficient way.
any help/pointers greatly appreciated.