Learning ASP. NET MVC5 framework secrets notes-ASP. net mvc routing (5), mvc5-asp.net

Source: Internet
Author: User

Learning ASP. NET MVC5 framework secrets notes-ASP. net mvc routing (5), mvc5-asp.net
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.

<?xml version="1.0" encoding="utf-8"?><!--This file is automatically generated. Please do not modify the contents ofthis file.--><typeCache lastModified="3/3/2014 10:06:29 AM"mvcVersionId="72d59038-e845-45b1-853a-70864614e003"><assembly name="Artech.Admin, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null"><module versionId="07be22a1-781d-4ade-bd22-34b0850445ef"><type>Artech.Admin.AdminAreaRegistration</type></module></assembly><assembly name="Artech.Portal, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null"><module versionId="7b0490d4-427e-43cb-8cb5-ac1292bd4976"><type>Artech.Portal.PortalAreaRegistration</type></module></assembly></typeCache>


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.

 

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.