ControlBuilderInterceptor class
The ControlBuilderInterceptor
class allows the compilation process to be customized or controlled.
Syntax
internal class ControlBuilderInterceptor
Warning
The ControlBuilderInterceptor
class is internal and is not meant to be used directly in your code.
As described in the Remarks section, the existence of this type can be checked to determine whether interceptor type support is present. Microsoft does not support any other use of this class in a production application under any circumstance.
Remarks
In .NET Framework 2.0 and .NET Framework 3.5, the August 2020 updates added support for using an interceptor type to customize or control the compilation process. You can determine whether this support is present by using Type.GetType() to check the existence of the ControlBuilderInterceptor
type, as demonstrated in the following code.
Type type = Type.GetType("System.Web.Compilation.ControlBuilderInterceptor, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
If the return value is non-null, then interceptor support is present. If the return value is null
, or if an exception is thrown, then the August 2020 updates have not been installed, and interceptor support is absent.
If interceptor support is present, you can write and register an interceptor type that will interact with the compilation process in exactly the same way that ControlBuilderInterceptor does on later versions of .NET Framework. In .NET Framework 2.0 and .NET Framework 3.5, the interceptor type can be any class that meets the following requirements:
- Has a public, parameterless constructor.
- Has public, non-static methods named
PreControlBuilderInit
andOnProcessGeneratedCode
that have the same signature and semantics as the PreControlBuilderInit(ControlBuilder, TemplateParser, ControlBuilder, Type, String, String, IDictionary, IDictionary) and OnProcessGeneratedCode(ControlBuilder, CodeCompileUnit, CodeTypeDeclaration, CodeTypeDeclaration, CodeMemberMethod, CodeMemberMethod, IDictionary) methods, which exist in later versions of .NET Framework.
Register the interceptor type by using the aspnet:20ControlBuilderInterceptor
key in ASP.NET application settings (<appSettings>
). This application setting must be listed in your computer or application web.config file. Specify the interceptor type by using its assembly-qualified type name. The following example shows how to register an interceptor type named Fabrikam.Interceptor
.
<configuration>
...
<appSettings>
...
<add key="aspnet:20ControlBuilderInterceptor"
value="Fabrikam.Interceptor, Fabrikam, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2b3831f2f2b744f7" />
</appSettings>
</configuration>
To retrieve the assembly-qualified name of a type, use the Type.AssemblyQualifiedName property, as demonstrated in the following code.
string assemblyQualifiedName = typeof(Fabrikam.Interceptor).AssemblyQualifiedName;
When interceptor support is present, the compilation process interacts with the listed type in the manner described above. When interceptor support is absent, the application setting is ignored and has no effect.
Requirements
Namespace: System.Web.Compilation
Assembly: System.Web (in System.Web.dll)
.NET Framework versions: 3.5, 2.0