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

GetAndEnsureRedirectAsync #7

Closed
ardalis opened this issue Aug 10, 2022 · 0 comments · Fixed by #33
Closed

GetAndEnsureRedirectAsync #7

ardalis opened this issue Aug 10, 2022 · 0 comments · Fixed by #33

Comments

@ardalis
Copy link
Owner

ardalis commented Aug 10, 2022

Add a method that gets a route and ensures the response is a redirect. Add an optional string argument that is the expected path of the redirect. You'll probably need to configure the client to not automatically follow redirects.

Note I'm not sure we can perform this check without creating a new instance of HttpClient.

See: https://stackoverflow.com/questions/10453892/how-can-i-get-system-net-http-httpclient-to-not-follow-302-redirects

If we need a new instance, it won't really make sense to use an extension method on the existing instance. We could require that the instance we're given have this property set:

AllowAutoRedirect = false;

but there's no public property that shows that information on HttpClient that I see.

We might need to use reflection on the client to see if its handler's MaxRedirects is set to 0 or not.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant