Reputation:
I wondering if there is anyway to achieve a url like http://www.mycompany.com/user in MVC I tried using the catch all but could not get the user passed so I can do the look up.
Thanks
Upvotes: 3
Views: 269
Reputation: 28153
Something like this?
routes.MapRoute("User",
"{UserName}",
new { Controller = "User", Action = "Index", UserName = "" });
UPDATED:
add this constraint to the "User" route:
routes.MapRoute("User",
"{UserName}",
new { Controller = "User", Action = "Index", UserName = "" },
new { UserName = @"(\w|-)+" }
);
or add this route:
routes.MapRoute("Home",
String.Empty,
new { Controller = "Home", Action = "Index", Id = "" }
);
Upvotes: 1