standards-c-sharp

Use attribute-based routing instead of convention-based routing

Don’t

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 }  
        );  
    }  
}  

Do

public class HomeController: Controller  
{  
    [Route("{department}/employees/{employeeId ?}")]  
    public string Employee(string department, int? employeeId)  
    {  
        ...
    }  
}