The timely compilation model of ASP. NET 2.0 is different from that of ASP. NET 1.1. Microsoft redesigned the page generation process of ASP. NET 2.0 so that the process can be controlled more flexibly.
I will not repeat the specific process here. You can refer to the following two articles:
Inside ASP. NET 2.0-instant compilation system
Jaw-dropping experience with M build providers
In ASP. NET 2.0, We can compile special files by implementing our own buildprovider. The file content is not limited, as long as you can parse the file in buildprovider and return the. NET codedom. Therefore, you can even use your own programming language to Develop ASP. NET programs.
In fact, Asp. some new features in net 2.0 are implemented through buildprovider, such. ashx files, mastpage, etc.. net installation directory. find the default buildprovider configurations in config.
In the afternoon, a simple experiment was conducted to generate entity class code through a custom XML format configuration file. You only need to place the following format in the app_code directory. dbconfig file, Asp. net will generate an assembly of the entity class through the custom buildprovider. You can also see the class of this Assembly from the intelligent awareness of the Code Editor. Is it cool?
1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <database connection = "">
3 <tables>
4
5 <Table name = "members">
6 <columns>
7 <column name = "ID" type = "integer"/>
8 <column name = "name" type = "varchar"/>
9 <column name = "email" type = "varchar"/>
10 </columns>
11 </table>
12
13 <Table name = "workitems">
14 <columns>
15 <column name = "ID" type = "integer"/>
16 <column name = "subject" type = "varchar"/>
17 <column name = "remark" type = "varchar"/>
18 <column name = "created_on" type = "datetime"/>
19 </columns>
20 </table>
21
22 </Tables>
23 </database>
The effect of the Assembly generated by the preceding configuration file in the editor is as follows:
To achieve the above effect, add this configuration in the system. web section of the web. config file. It declares that the. dbconfig file is handed over to entitybuildprovider for processing.
1 <compilation DEBUG = "true">
2 <buildproviders>
3 <add extension = ". dbconfig" type = "mybuildprovider. entitybuildprovider"/>
4 </buildproviders>
5 </compilation>
For more information about compilation configuration nodes, refer to the following on msdn:
Compilation element (ASP. NET architecture)
Custom buildprovider requires codedom-related knowledge. If you didn't know much about codedom before, refer to the following two articles:
Microsoft. NET codedom technology-Part 1
Microsoft. NET codedom technology-Part 2
Through the afternoon experiment, we found that buildprovider is powerful, but can only be used in the website project. It is ineffective to use it in the webapplication project .... No alternative solution has been found in webapplication mode. If anyone knows, leave a message to teach me.
Recently, I have been wondering how to make the blog template system highly scalable, with a good user experience without affecting execution efficiency. Therefore, buildprovider and some other advanced features that are not commonly used in ASP. NET. The more I think about it, the more I don't understand it. But I also learned a lot of things I didn't pay attention to before. Haha.
If you want. net's complete request processing process includes a more in-depth understanding of the dynamic compilation process. Currently, the best way I know is to use reflector to open the system. web Assembly, from httpruntion. start with processrequest. This article describes ASP. NET 1.1 in combination with a low-level look at the ASP. NET architecture. If you have a better solution, please let me know
My lab project in the afternoon:
Buildproviderdemo.rar
Note:
1. If the website project is not included in the project due to path change, manually re-include the project.
2. We can see that only the mybuildprovider. Demo project works, and the buildproviderdemo Project is a webapplication-type buildprovider.
3. If your Visual Studio 2005 is not a team Suite version, you may need to remove the unit test project to open the solution.
4. If you have not installed a webapplication Project template or VS 2005 SP1, you must remove the buildproviderdemo project.