larryq
larryq

Reputation: 16309

Personalization in ASP.Net MVC -- friendly URLs, and skinning

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 create 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.

Upvotes: 1

Views: 843

Answers (1)

Maslow
Maslow

Reputation: 18746

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.

Upvotes: 1

Related Questions