0

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

1 Answer 1

0

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="" });
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Mika Kolari, Thanks For your answer very nice it is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.