Areas provides a way to divide large ASP. NET Core MVC Web applications into smaller functional groupings, which are necessary for region-by-region routing, and the following are two ways to implement zone routing easily
1 This method must add a zone attribute to the controller, that is, the route automatically matches all controllers that add routing attributes
1 //Routing2Routes. MapRoute (Name:"Arearoute",3Template"{Area:exists}/{controller=myhome}/{action=index}");4 5 //Controller Add Property6[Area ("Manage")]7 Public classUserinfocontroller:controller8 {9 Private ReadOnlyiunitofwork _unitofwork;Ten Private ReadOnlyIuserinfoservice _userinfoservice; One A PublicUserinfocontroller (Iuserinfoservice userinfoservice, iunitofwork unitofwork) - { -_unitofwork =unitofwork; the_userinfoservice =Userinfoservice; - } - Publiciactionresult Index () - { + returnView (); - } +}
2 This route does not need to add a zone attribute [area ("Manage")] to the controller, which means adding a route to the zone for each zone added
1 Routes. Maparearoute ("manage_route""Manage",2 "manage/{controller=myhome}/{action=index}/{id?} " 3 );
ASP. NET Core Zone routing