Skip to content

FormFeature initialized with an IFormCollection instance throws NullReferenceException in Form property getter #53099

@johatuni

Description

@johatuni

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When the FormFeature type is constructed with an IFormCollection instance, the internal field _request is initialized to "default!" (null) in the ctor. When later accessing the Form property, a NullReferenceException is thrown from inside the private ResolveHasInvalidAntiforgeryValidationFeature() method, since it does not have a null guard for the _request field.

image

Expected Behavior

The Form property should in this case return the IFormCollection used when constructing the instance of the FormFeature.

Steps To Reproduce

No response

Exceptions (if any)

NullReferenceException

.NET Version

8

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions