Asp.net mvc5 is easy to implement plug-in development and mvc5 is easy to implement

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.