-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Blazor WASM - Set Fetch redirect to manual #44740
Comments
Not sure if it is possible to get that information in the browser (not everything in the dev tools is available from JavaScript). FYI: #41394 is only in the 6.0.0 milestone and not in the current 5.0.0 release. |
Tagging subscribers to this area: @dotnet/ncl Issue Details
|
I believe this is also a blocker for the Octokit.Net |
I have done some more investigation and it seems this is how
So it doesn't work the way I thought it would do.... It fact with the headers empty there's no way to do the redirect manually, which in my mind defeats the meaning of 'manual'. I did also look into FetchEvents, so maybe an event will be fired when a redirect occurs? So I think you can close this issue for now. |
@LukeTOBrien thank you for looking into this more. As you confirm the redirect from the fetch works differently than one would expect. Here is the original PR that introduced the ability: #41394 Some more references on how the browser handles the AllowAutoRedirect and why certain information is not allowed to be returned per browser security rules. References: |
Woah this is long, I did not want this... I feel guilty adding another issue when you have 2.4K 😲
Problem/what I am trying to do
Many sites use shortlinks to allow users to share links to a blog page or media etc. The case I am working with is Sketchfab.
A shortlink like https://skfb.ly/WVBN points to a 3D model.
I noticed that the shortlink is resolved by performing another GET request to https://sketchfab.com/s/WVBN, which inturn redirects to the full URL of the 3D model.
The request to https://sketchfab.com/s/WVBN returns a
301
status code with the URL of the 3D model caintained in thelocation
header.So what I would like to do is to make a request to resolve to shortlink and read the
location
header and not auto-follow the redirect.The JavaScript fetch API takes a parameter for
redirect
, the options are:follow
error
manual
The following code gives a not supported on platform exception:
After upgrading my project to .Net5 the following code seems to prevent the rediect via way of a canceled request:
(This did not work before updating)
Make the request.
In my code I can also log the status code, but the status code is 0.
Console.WriteLine("STATUS CODE " + response.StatusCode.ToString());
What I would expect is the canceled request not to be made at all and for the response status code to be
301
with thelocation
header value set.Describe the solution you'd like
HttpClientHandler.AllowAutoRedirect Property should work on the Blazor WASM platform and the following code should set the
redirect
parameter tomanual
on the Fetch Api:And the response should return with status code 301 with the
location
header set as it does in the F12 dev tools.Additional context
I have read #41394 (resposible for
request.SetBrowserRequestOption("redirect", "manual");
?)And I have read #39365
The text was updated successfully, but these errors were encountered: