Skip to content

Overridden razor page lifecycle methods detected as page handlers #63692

@lakeman

Description

@lakeman

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Any razor page model, with an overridden PageModel.OnPageHandler* method, without an explicit [NonHandler] attribute, will be discovered as a potential page handler. Which is a little surprising. eg;

public class MyPageModel : PageModel
{
    public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
    {
        // something....
        base.OnPageHandlerExecuting(context);
    }
}

I believe that this is due to comparing against methodInfo.DeclaringType, instead of methodInfo.GetBaseDefinition().DeclaringType in the following test;

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions