views:

39

answers:

1

Hi, I am using MVC 2.0 to create my application,my problem i s related to the routing. Actually in my application each user have required seperate subdomain,like www.example.com/user1/ ,www.example.com/user2/ ...etc.the default domain is www.example.com.So how can i make it possible with routing in mvc. i have tried like this,

 routes.Add(new Route(
   "{id}", 
   new RouteValueDictionary(
       new { controller = "User", action = "login", id = " " }
   ), new MvcRouteHandler()));

   var defaults = new RouteValueDictionary(
      new
      {
           controller = "Home",
           action = "Index",
           id = UrlParameter.Optional

      }
   );

   routes.Add(new Route(
     "{controller}/{action}/{id}", 
    defaults, 
    new MvcRouteHandler()));

But the problem is that it take deafult (www.example.com) directly to user login page.I want the default page as Home/index and when www.example.com/user1/ it will go to user login page.Is there any way ..pls help me

A: 

You could map a specific route for the home page.

routes.MapRoute("home","", new{controller="Home",action="Index"});
routes.MapRoute("users", "{username}/{action}", new { controller = "Users", action = "Login",username="" });
Mika Kolari
Hi Mika Kolari, Thanks For your answer very nice it is working.
suneehs