Learn the ASP. MVC5 Framework Secret Note-asp.net MVC Route (v)

Source: Internet
Author: User

2.AreaRegistrationthe Cache

Areathe registration (mainly based on Arearoute map registration) through a specificarearegistrationto complete. When the app starts,ASP . NET MVCis traversed by calling theBuildManagerthe static methodgetreferencedassembliesGets the list of assemblies and finds allarearegistrationtype. If an app involves too many assemblies, this process can take a lot of time. To improve performance,ASP . NET MVCwill be resolved to all thearearegistrationThe type list is cached.

ASP. NET MVCthearearegistrationthe cache of type lists is file-based. Specifically, whenASP . NET MVCThe framework is loaded by the assembly and the type reflection gets all thearearegistrationType list, it serializes it and saves the serialized result as a physical file. This name is "Mvc-arearegistrationtypecache-xml"ofXMLfiles are saved inASPin the temporary directory, the specific path is as follows. The first one for boardingLocal IISin theWebapplication, the latter for direct adoptionVisual Studio Developer ServerorIIS Expressas the host app.

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 followingXMLfragment embodies this as allarearegistrationType-CachedXMLthe structure of the file. We can see all thearearegistrationthe name of the type, together with the managed module and assembly name where it resides, is saved. Whenarearegistrationthe static methodRegisterallareasafter being called, the system attempts to load the file, and if the file exists and has the desired structure, then the system will no longer parse the assembly load and reflection to resolve allarearegistrationand instead directly deserializes the contents of the file to get allarearegistrationa list of types.

<?xml version= "1.0" encoding= "Utf-8"?><!--This file is automatically generated. 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 the wrong structure (which causes deserialization to fail for the arearegistration type list),ASP. The framework will re-parse all the arearegistration type lists as described above and serialize them into XML to save to the specified file. It is worth mentioning that Program compilation for WEB applications causes the purge of these cache files.

Learn the ASP. MVC5 Framework Secret Note-asp.net MVC Route (v)

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.