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.