Open samosim opened 2 months ago
@samosim thanks for contacting us.
Very likely you need to set the option in the underlying fetch request. We suggest you also check the network tab to see if the response came back as opaque, preventing JS from seeing it. It might also be a limitation on the browser sandbox.
Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.
@samosim thanks for contacting us.
Very likely you need to set the option in the underlying fetch request. We suggest you also check the network tab to see if the response came back as opaque, preventing JS from seeing it. It might also be a limitation on the browser sandbox.
Which options do you suggest to set? Attached, please find the snapshot from the network tab. Do you see any issues from this image?
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
cc @pavelsavara
AllowAutoRedirect = false
will set redirect = "manual"
https://github.com/dotnet/runtime/blob/56435ad8ce8cb1f6511d837d6b86707eeaf46ac3/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs#L188-L189 https://developer.mozilla.org/en-US/docs/Web/API/RequestInit#redirect
Which will strip out a lot of information from the response https://github.com/dotnet/runtime/blob/56435ad8ce8cb1f6511d837d6b86707eeaf46ac3/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs#L311-L313 https://developer.mozilla.org/en-US/docs/Web/API/Response/type
I am not sure if AllowAutoRedirect
can currently be implemented correctly since redirect = "manual"
does not what everybody thinks it does. I also learned that here: https://github.com/dotnet/aspnetcore/pull/52559#discussion_r1414162643
See also:
Is there an existing issue for this?
Describe the bug
Here is my test code in Blazor for HttpClient:
the reponse code is 0 and location is null. If I use the same code in Console application I get redirect code response with location. It is worth mentioning that redirect code together with location are shown in browser under the network tap. Additionally, I test the same request in Postman and it works just fine. Please let me know what the problem with Blazor for code response 0 is.
Expected Behavior
I should get the response code which reflects redirection together with location path.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
net 7.0
Anything else?
No response