संपादित करें

इसके माध्यम से साझा किया गया


PageParserFilter Class

Definition

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.

public ref class PageParserFilter abstract
public abstract class PageParserFilter
type PageParserFilter = class
Public MustInherit Class PageParserFilter
Inheritance
PageParserFilter

Examples

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.CS
{
    [PermissionSet(SecurityAction.Demand, Unrestricted = true)]
    public class CustomPageParserFilter : PageParserFilter
    {
        public override bool AllowCode
        {
            get 
            {
                return false;
            }
        }
    }
}
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>

Constructors

PageParserFilter()

Initializes a new instance of the PageParserFilter class.

Properties

AllowCode

Gets a value indicating whether an ASP.NET parser filter permits code on the page.

CalledFromParseControl

Gets a value that indicates whether the parser filter was called from the page.

Line

Gets the line number that is currently being parsed in the file.

NumberOfControlsAllowed

Gets the maximum number of controls that a parser filter can parse for a single page.

NumberOfDirectDependenciesAllowed

Gets the maximum number of direct file dependencies that the page parser permits for a single page.

TotalNumberOfDependenciesAllowed

Gets the maximum number of direct and indirect file dependencies that the page parser permits for a single page.

VirtualPath

Gets the virtual path to the page currently being parsed.

Methods

AddControl(Type, IDictionary)

Adds a ControlBuilder object in the page control tree at the current page parser position.

AllowBaseType(Type)

Determines whether the page can be derived from the specified Type.

AllowControl(Type, ControlBuilder)

Gets a value indicating whether the specified control type is allowed for this page.

AllowServerSideInclude(String)

Determines whether a parser permits a specific server-side include on a page.

AllowVirtualReference(String, VirtualReferenceType)

Determines whether a parser permits a virtual reference to a specific type of resource on a page.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetCompilationMode(CompilationMode)

Retrieves the current compilation mode for the page.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNoCompileUserControlType()

Returns a Type that should be used for pages or controls that are not dynamically compiled.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
Initialize()

Initializes a filter used for a page.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ParseComplete(ControlBuilder)

Called by an ASP.NET page parser to notify a filter when the parsing of a page is complete.

PreprocessDirective(String, IDictionary)

Allows the page parser filter to preprocess page directives.

ProcessCodeConstruct(CodeConstructType, String)

Returns a value that indicates whether a code block should be processed by subsequent parser filters.

ProcessDataBindingAttribute(String, String, String)

Returns a value that indicates whether the parser filter processes a data binding expression in an attribute.

ProcessEventHookup(String, String, String)

Returns a value that indicates whether event handlers should be processed further by the parser filter.

SetPageProperty(String, String, String)

Sets a property on a control derived from the TemplateControl class, which includes the Page, UserControl, and MasterPage controls.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also