How to make routing in asp.net mvc domainname/username so each user has his "username" like facebook does
Thank you in advance!
You just use the username part as the {id} element, and have a default {action}.
Try This
routes.MapRoute(
"users", // Route name
"{username}", // URL with parameters
new { controller = "Home", action = "User" } // Parameter defaults
);
and this will be first MapRoute, and action would be like
public ActionResult User(string username)
{
return View();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With