Notes on learning ASP. NET MVC5 framework-ASP. net mvc Routing

Source: Internet
Author: User

Notes on learning ASP. NET MVC5 framework-ASP. net mvc Routing
2. cache of AreaRegistration

The registration of Area (mainly the registration of Area-based route ing) is completed through the specific AreaRegistration. When the application is started, ASP. net mvc traverses the Assembly list obtained by calling the static method GetReferencedAssemblies of BuildManager and finds all AreaRegistration types. If an application involves too many assemblies, this process may take a lot of time. To improve performance, ASP. net mvc caches the list of parsed AreaRegistration types.

ASP. net mvc caches the AreaRegistration type list based on files. Specifically, when the ASP. net mvc Framework obtains a list Of all AreaRegistration types through Assembly Loading and type reflection, it serializes and saves the serialized results as a physical file. The xml file "MVC-AreaRegistrationTypeCache-XML" is saved in the temporary directory of ASP. NET. The specific path is as follows. The first is for Web applications hosted in Local IIS, and the latter is for applications directly hosted by Visual Studio Developer Server or IIS Express.

1.% Windir % \ Microsoft. NET \ Framework \ v {version} \ TemporaryASP. NET Files \ {appname} \... \ UserCache \

2.% Windir % \ Microsoft. NET \ Framework \ v {version} \ TemporaryASP. NET Files \ root \... \ UserCache \

The following XML snippet shows the structure of the XML file cached as all AreaRegistration types. We can see that the names of all AreaRegistration types, together with the managed modules and Assembly names, are saved. When the static method RegisterAllAreas of AreaRegistration is called, The system tries to load the file. If the file exists and has the expected structure, the system will not parse all AreaRegistration types through Assembly Loading and reflection, but will directly deserialize the file content to get a list of all AreaRegistration types.

 

 
 
 
  
   
    Artech.Admin.AdminAreaRegistration
   
  
  
   
    Artech.Portal.PortalAreaRegistration
   
  
 


 

If such XML does not exist or has an incorrect structure (this will cause deserialization failure for the AreaRegistration type list), ASP. net mvc Framework will re-Parse all AreaRegistration type lists according to the above method, and serialize them into XML and save them to the specified file. It is worth mentioning that the compilation of Web applications will prompt the cleanup of these cache files.

 

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.