The Wayback Machine - https://web.archive.org/web/20210729013324/https://github.com/dotnet/aspnetcore/issues/33218
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpClient created by WebApplicationFactory doesn't follow HTTP status code 303 (See other) redirect #33218

Open
ambrosmiroslav opened this issue Jun 2, 2021 · 2 comments

Comments

@ambrosmiroslav
Copy link
Contributor

@ambrosmiroslav ambrosmiroslav commented Jun 2, 2021

The HttpClient created "manually" is able to follow HTTP status code 303 (See other) and jump to redirected page:

        _client = new HttpClient();

But the HttpClient retrieved from WebApplicationFactory isn't:

        public ClientContext(WebApplicationFactory<MyProject.Startup> Factory)
        {
                    _client = Factory.CreateClient();
        }

No matter the WebApplicationFactoryClientOptions are specified or not...

Could it be this HTTP status code is not mentioned in https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.Testing/src/Handlers/RedirectHandler.cs, see the function IsRedirect()?

        private bool IsRedirect(HttpResponseMessage response) =>
            response.StatusCode == HttpStatusCode.MovedPermanently ||
                response.StatusCode == HttpStatusCode.Redirect ||
                response.StatusCode == HttpStatusCode.RedirectKeepVerb ||
                (int)response.StatusCode == 308;
@javiercn
Copy link
Contributor

@javiercn javiercn commented Jun 2, 2021

@ambrosmiroslav thanks for contacting us.

We would be happy to take a PR for this including the change and a test to verify the change if you want to contribute it.

@javiercn javiercn added this to the Backlog milestone Jun 2, 2021
@msftbot
Copy link
Contributor

@msftbot msftbot bot commented Jun 2, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ambrosmiroslav ambrosmiroslav changed the title HttpClient created by WebApplicationFactory doesn't follow HTTP status code 302 (See other) redirect HttpClient created by WebApplicationFactory doesn't follow HTTP status code 303 (See other) redirect Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants