We know that some temporary files are required for processing ASP. NET page requests.ProgramLogic is of great help. Here are two methods:
First, add
Protected Void Page_load ( Object Sender, eventargs E)
{
Response. Write (This. GetType (). Assembly. Location );
}
The output is similar to the following string:
C: \ windows \ Microsoft. NET \ framework \ v2.0.50727 \ temporary ASP. Net files \ website13 \ 63ed8704 \ 93b8f11b \ app_web_rixp4_rs.dll
Remove the last app_web_rixp4_rs.dll character, copy the remaining strings to the "run" window, and open the corresponding folder.
Take the default. aspx page as an example. Find the file default2.aspx. cdcab7d2. compiled in the opened folder.
Open this file and you will see something similar to the following:
<? XML version = "1.0" encoding = "UTF-8" ?>
< Preserve Resulttype = "3" Virtualpath = "/Website13/default. aspx" Hash = "73ae13447" Filehash = "Ffffe207cb3bfc04" Flags = "110000" Assembly = "App_web_rixp4_rs" Type = "ASP. default_aspx" >
< Filedeps >
< Filedep Name = "/Website13/default. aspx" />
</ Filedeps >
</ Preserve >
In the open file, find Assembly = "app_web_rixp4_rs" and find the class file starting with app_web_rixp4_rs in the file you just opened. These files are the temporary files we need.
Second, we write a file that inherits the ihttphandlerfactory interface.
Public Class Httphandlerfactory: ihttphandlerfactory
{
Public Virtual Ihttphandler gethandler (httpcontext context, String Requesttype, String URL, String Pathtranslated)
{
// Get the compilation instance (through reflection)
Pagehandlerfactory Factory = (Pagehandlerfactory) activator. createinstance ( Typeof (Pagehandlerfactory ), True );
Ihttphandler Handler = Factory. gethandler (context, requesttype, URL, pathtranslated );
Responseassemblylocation (context, Handler );
// Return
Return Handler;
}
Public Virtual Void Releasehandler (ihttphandler handler)
{
}
[Conditional ( " Debug " )]
Private Void Responseassemblylocation (httpcontext context, ihttphandler handler)
{
Context. response. Write (handler. GetType (). Assembly. Location );
}
}
Configure in Web. config: < Httphandlers >
< Add Verb = "*" Path = "*. Aspx" Validate = "False" Type = "Httphandlerfactory" />
</ Httphandlers >
< Compilation Debug = "True" />
When DEBUG = "true", the responseassemblylocation method in the httphandlerfactory class can be executed. Otherwise, the method is not executed.
Note that the class file httphandlerfactory generated is in the app_code directory of the website. Therefore, the Assembly name is not configured in the type section of the web. config file.