How to use personalized urls in asp.net mvc application


How to use personalized urls in asp.net mvc application



I am working on a website in which many users can create their account and have a personalized page. I wish to provide them a twitter like url to access their pages, for example www.mysite.com/smith or www.mysite.com/john . I am using asp.net mvc 1.0. I have an understand that i can add routes to the global.asax file, but i am not able to figure out how to add a route that will work for such urls.

Please provide some help / suggestions. Thanks.


ASP.net/MVC file upload with URL rewrite enabled

1:

Empty asp.net Resources Cache, provided by SQLResourceProvider
Well, you must always add this as a last route:. Sending data to server (ASP.NET MVC) with Ajax(jQuery) through JSON
routes.MapRoute(     "Default",     "{profile}",     new { controller = "Profile", action = "Index" } ); 
although this will make your app more cumberany . How to get the Url for urlAction helper class?Specifically, you'll have to check usernames so this they don't collide with the rest of your routes (like /info, '/admin' etc.).. calling a jquery function from asp.net mvc action What I recommend is to move personalization page one level deeper:. How to register javascript in ASP.NET MVC action?
routes.MapRoute(     "Default",     "profile/{username}",     new { controller = "Profile", action = "Index" } ); 
Can I deny access to a Wordpress directory with MVC 2?Why won't my MVC project work after publishing it?

2:

For my part, I would use the following, placed after all another routes, although befare a catchall:.
routes.MapRoute(      "PrettyProfile",      "{username}",      new { controller = "Profile", action = "Index" }  );  
As Anton says, you have to constrain your userIDs not to clash with your another routes..


82 out of 100 based on 37 user ratings 792 reviews