The asp.net sample contains a sample Dotfuscator configuration file that demonstrates using exclusion rules to handle items referenced in an aspx file that are define in the code-behind assembly. This file is named asp_config.xml and can be located in the same directory as the rest of the asp.net samples. The section of the file that excludes these references is:
<renaming> <excludelist> <type name="DotfuscatorASP.Sample"> <field name="CountLabel"/> </type> </excludelist> … </renaming>
<renaming> tag indicates that the exclusion rules contained within pertain specifically to identifier renaming, as opposed to other Dotfuscator features which can also be selectively turned on or off.
<excludelist> tag defines a list of items which must be excluded from the renaming process. The
> tag instructs Dotfuscator to exclude the class name "
DotfuscatorASP.Sample" from the renaming process. Note that this only refers to the class name itself. All methods of the "
Tester" class are still eligible for renaming. This is required since the aspx file inherits from this class. The
<field name="CountLabel"/> tag instructs Dotfuscator to exclude the server-side label control that displays the page load count.
Executing the run.bat file will run Dotfuscator with this configuration file. The output of this process is a DotfuscatorASP.dll assembly in the "
output" subdirectory. This location can be controlled by modifying the following section in the configuration file:
<output> <file dir="output" /> </output>
Executing the deploy.bat file will copy the obfuscated assembly into the bin directory that will be searched by the web server. This will overwrite the non-obfuscated assembly.
Visiting the website with the browser verifies that Dotfuscator correctly excluded the required items from the renaming process. Note that the load count has been reset to the default value indicating that IIS has reloaded the new assembly.