Skip to content

NullReferenceException is thrown by Microsoft.AspNetCore.Mvc.Testing.Handlers.RedirectHandler #27035

@hankovich

Description

@hankovich

RedirectHandler is added by default to a HttpClient produced by WebApplicationFactory<TEntryPoint>.

When the server returns a result with one the following codes

  • 301 Moved Permanently
  • 302 Found
  • 307 Temporary Redirect
  • 308 Permanent Redirect

but without a Location header, NullReferenceException is thrown here.

For all mentioned status codes rfc7538 and rfc7231 say 'The server SHOULD generate a Location header field', so it's not required.

Expected behavior: Exception is not thrown, response is returned as is (like HttpClient does in the same situation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.community-contributionIndicates that the PR has been added by a community membergood first issueGood for newcomers.investigateseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions