How do I make my application route to mydomainname/username/controller.
I am working on asp.net mvc web application that enables a user to belong to multiple account. ie. In the application every account has its own users, and each user in one account can also be a user in another account. What i need is when a user wants to login, they specify the account they want to be logged to like this: domainname.com/accountname/login.
Am able to do this, but where am having issue is how to persist the accountname route parameter across other routes? I mean making it to be visible on the url. For now am using cookie to store and get the accountname parameter, but i need a way to make it visible on the url in every request (without having to manually route it on links) until the user singout.
Am using asp.net mvc 2
Edit: Added my route code
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("", "", new { controller = "Home", action = "index" });
routes.MapRoute("", "dashboard", new { controller = "account", action = "dashboard" });
routes.MapRoute("", "contacts", new { controller = "contact", action = "index" });
routes.MapRoute("", "groups", new { controller = "group", action = "index" });
routes.MapRoute("", "sms", new { controller = "sms", action = "index" });
routes.MapRoute("", "users", new { controller = "user", action = "index" });
routes.MapRoute("", "login", new { controller = "Home", action = "login", accountUrlName = UrlParameter.Optional });
routes.MapRoute("", "{accountUrlName}/login", new { controller = "Home", action = "login" });
routes.MapRoute("", "register", new { controller = "home", action = "register" });
routes.MapRoute("", "{accountUrlName}/invitations/{ivkey}", new { controller = "home", action = "invitations" });
routes.MapRoute("", "{urlName}",
new { controller = "home", action = "index", urlName = UrlParameter.Optional });
routes.MapRoute("", "{accountUrlName}/{action}",
new { controller = "account", action = "dashboard", id = "", accountUrlName = UrlParameter.Optional });
routes.MapRoute("", "{accountUrlName}/{controller}/{action}/{id}",
new { controller = "account", action = "dashboard", id = "", accountUrlName = ""});
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}