Export (0) Print
Expand All

PageParserFilter Class

Provides an abstract base class for a page parser filter that is used by the ASP.NET parser to determine whether an item is allowed in the page at parse time.

System.Object
  System.Web.UI.PageParserFilter

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Medium)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Medium)> _
Public MustInherit Class PageParserFilter

The PageParserFilter type exposes the following members.

  NameDescription
Protected methodPageParserFilterInitializes a new instance of the PageParserFilter class.
Top

  NameDescription
Public propertyAllowCodeGets a value indicating whether an ASP.NET parser filter permits code on the page.
Protected propertyCalledFromParseControlGets a value that indicates whether the parser filter was called from the page.
Protected propertyLineGets the line number that is currently being parsed in the file.
Public propertyNumberOfControlsAllowedGets the maximum number of controls that a parser filter can parse for a single page.
Public propertyNumberOfDirectDependenciesAllowedGets the maximum number of direct file dependencies that the page parser permits for a single page.
Public propertyTotalNumberOfDependenciesAllowedGets the maximum number of direct and indirect file dependencies that the page parser permits for a single page.
Protected propertyVirtualPathGets the virtual path to the page currently being parsed.
Top

  NameDescription
Protected methodAddControlAdds a ControlBuilder object in the page control tree at the current page parser position.
Public methodAllowBaseTypeDetermines whether the page can be derived from the specified Type.
Public methodAllowControlGets a value indicating whether the specified control type is allowed for this page.
Public methodAllowServerSideIncludeDetermines whether a parser permits a specific server-side include on a page.
Public methodAllowVirtualReferenceDetermines whether a parser permits a virtual reference to a specific type of resource on a page.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetCompilationModeRetrieves the current compilation mode for the page.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetNoCompileUserControlTypeReturns a Type that should be used for pages or controls that are not dynamically compiled.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodInitializeInitializes a filter used for a page.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodParseCompleteInfrastructure. Called by an ASP.NET page parser to notify a filter when the parsing of a page is complete.
Public methodPreprocessDirectiveAllows the page parser filter to preprocess page directives.
Public methodProcessCodeConstructReturns a value that indicates whether a code block should be processed by subsequent parser filters.
Public methodProcessDataBindingAttributeReturns a value that indicates whether the parser filter processes a data binding expression in an attribute.
Public methodProcessEventHookupReturns a value that indicates whether event handlers should be processed further by the parser filter.
Protected methodSetPagePropertySets a property on a control derived from the TemplateControl class, which includes the Page, UserControl, and MasterPage controls.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The following example demonstrates how you can create a class that derives from the PageParserFilter class to govern the behavior of the ASP.NET page parser. The CustomPageParserFilter is a parser filter that explicitly rejects code in the page. It does this by overriding the AllowCode property.

Namespace Samples.AspNet.VB
    <PermissionSet(SecurityAction.Demand, Unrestricted := true)> _
    Public Class CustomPageParserFilter
        Inherits PageParserFilter

        Public Overrides ReadOnly Property AllowCode() As Boolean 
            Get 
                Return False 
            End Get 
        End Property 

    End Class 
End Namespace

To use the CustomPageParserFilter sample, place the class in your App_Code directory. You must configure the ASP.NET parsers to use the filter in the pages section of your site's Web.config configuration file. The following example configuration file shows the configuration for CustomPageParserFilter. When configured to use a parser filter, the ASP.NET parser throws an exception during the build if it encounters code in a page.

<?xml version="1.0" ?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<system.web>

<pages

pageParserFilterType="Samples.AspNet.CS.CustomPageParserFilter">

</pages>

</system.web>

</configuration>

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft