Hi, 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
Hi, 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
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 = "" }
);