To fully understand ASP. net http runtime, let's analyze the changes in the file system layer when requesting ASP. NET pages. Next, you will learn about a group of dynamically created temporary files managed and monitored by HTTP MPs queue objects.
Although the core code of the page can be isolated from the C # or Microsoft Visual Basic. Net class behind the code, the web page can be written and deployed as a. aspx text file. For pages to be displayed as URLs, The. aspx file must always be available in the web space of the application .. The actual content of the aspx file determines the Assembly (or multiple Assembly) to be loaded by the Application object ).
According to the design,HttpapplicationThe object will look for a class named according to the requested aspx file. If the page is named sample. aspx, the corresponding class to be loaded is namedASP. sample_aspx. Application objects search for such classes in all Assembly folders of the Web application, including the Global Assembly Cache (GAC), Bin subfolders, and temporary ASP. NET files folders. If such a class is not found, the HTTP structure will be analyzed. source code of the aspx file, create a C # Or Visual Basic.. Net class. the language set on the ASPX page), and compile it at the same time. The name of the newly created assembly is randomly generated and located in the application-specific subfolders. The path is as follows: C: \ WINDOWS \ Microsoft. net \ framework \ v1.1.4322 \ temporary ASP.. Net files.
Subfolders v1.1.4322 are specific to ASP. NET 1.1. If you are using ASP. NET 1.0, the sub-Folder version will be different, that is, the sub-Folder name is v1.0.3705. When you access the page again, the Assembly already exists and does not need to be created again. However,HttpapplicationHow does an object determine whether the page-specific Assembly exists? Does it scan a large number of folders each time? No, not like this.
The application object only displays the content of a special folder in the temporary ASP. NET Files folder. The specific path (application-specific path) consistsHttpruntime. codegendirProperty return. If this is the first time you access the. aspx file (that is, the page assembly has not been created), there will be no XML file starting with the ASPX page name in this folder. For example, the sample. ASPX page with dynamic assembly should have the following entries:
sample.aspx.XXXXX.xml
The XXXXX placeholder is a hash code. By reading the content of the XML file, the application object can understand the name of the assembly to be loaded and the class to be obtained in it. The following code snippet is a typical content of this helper file. IncludeASP. sample_aspxThe Assembly name of the class is mvxvx8xr.
<preserve assem="mvxvx8xr" type="ASP.sample_aspx"><filedep name="c:\inetpub\wwwroot\vdir\sample.aspx" /></preserve>
Of course, this file is created only when the source code of the filedep file is analyzed to generate a dynamic assembly. Any changes made to the filedep file will invalidate the Assembly and must be re-compiled in the next request.Note that the implementation process may change significantly in future versions of the ASP. NET architecture.For whatever reason, you must be very careful as long as you decide to use it in the current application.
ASP. NET verifies whether the old assembly can be deleted to create a new assembly for the page due to updates. If the old Assembly only contains the modified page class, ASP. NET will try to Delete and replace the modified assembly. Otherwise, a new assembly will be created while the old assembly is retained.
During the deletion process, ASP. NET may find that the Assembly file has been loaded and locked. In this case, you can add a ". Delete" extension for the old assembly to rename it. (Note: All Windows files can be renamed during use .) As long as the application is restarted (for example, due to changes to an application file such as Global. asax and web. config), these temporary. delete files will be deleted. However, ASP. NET does not delete these files when processing the next request.
Note that by default, each ASP. NET application can recompile up to 15 pages before the entire application restarts, and some session and application data will be lost. When the number of recent compilations exceeds NumrecompilesbeforeapprestartWhen the threshold value is set in the property, the appdomain is uninstalled and the application is restarted. Note that in. NET Framework, You Cannot uninstall a single assembly. Appdomain is the smallest code block that can be detached from CLR.