I am building a blog engine using MVC 3 and razor. In this scenario, I have given options like a user can have multiple blogs (similar to blogger.com)
Now say a user ‘yasser’ has the following 3 blogs
- TechStory
- GameGeek
- MeMyStory
so I want all other users to access these blogs by the following urls
- http://www.domainName.com/blogs/TechStory
- http://www.domainName.com/blogs/GameGeek
- http://www.domainName.com/blogs/MeMyStory
And more blogs can be added hence more such url will be acessed in future.
I know that something needs to be done with Routing, but being new to MVC dont seems to get it. Please can some one guide me on this.
Add this route on top of your Default one:
Your controller will look like this:
Also, one suggestion: Keep your controller names in singular mode: BlogController instead of BlogsController. Change URL and Routing accordingly if you decide to do so.