Asp.net mvc5 is easy to implement plug-in development and mvc5 is easy to implement
When studying the Nopcommece project code, we found that Nop. Admin was developed as an independent project, but it was integrated during deployment.
Here, we extract this part separately,
Key points:
Here, an AdminAreaRegistration is created to register WebAdmin-related routes. The advantage is that each plug-in is responsible for its own tasks and does not affect each other,
But when will this RegisterArea be executed? When the main website project calls AreaRegistration. RegisterAllAreas,
So what does AreaRegistration. RegisterAllAreas () mainly do?
ASP. net mvc traverses the Assembly list obtained by calling the static method GetReferencedAssemblies of BuildManager and finds all arearegiation types,
Call the RegisterArea method of each AreaRegistration type.
Note that this is a simple method, because this example simply outputs the DLL of the plug-in project to the Bin directory of the main project,
The plug-in DLL can be successfully added to the GetReferencedAssemblies list,
If you want each plug-in to have its own directory, you may need to manually add each plug-in DLL to the GetReferencedAssemblies list before APPStart through BuildManager,
Code download: https://github.com/xlb378917466/SimplePlugin_asp.netmvc5.git