public class Global
{
public void Application_Start()
{
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
public class HomeController: Controller
{
[Route("{department}/employees/{employeeId ?}")]
public string Employee(string department, int? employeeId)
{
...
}
}