I haven't delved into custom generation of friendly URLs in ASP.Net MVC, and was wondering if anyone had suggestions. For example, if John Smith were to cre开发者_开发知识库ate an account on www.example.com, I'd like for his homepage to read www.example.com/JohnSmith -- along with the option for him to choose his URL. The ideal is for this to happen with no intervention on my part in the route maps.
Also, does anyone have guidelines on good ways to go to customize an MVC site based on URL? Again, using example.com I'd like for John to choose a color theme and logo for his homepage, then apply it accordingly.
Thanks for your tips and suggestions.
You can use routing for this where the second part is a key to which site it is.
routes.MapRoute(
"Default", // Route name
"{site}/{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
so that site becomes a variable available to every action.
精彩评论