SimpleBrowserDotNet/SimpleBrowser

.Net Core browsing to a link using Status 302 for redirect

mikaelliljedahl opened this issue · 6 comments

I don't know about .Net Core support, but it seems there is a flaw:

Whenever i navigate to a page which has a redirect, the Navigate() method returns false, and the LastWebException is {"The remote server returned an error: (302) ."}

This is due to another way the .net Core framework handles that error status:
https://github.com/dotnet/corefx/issues/23422

One workaround for this would be a try catch around the web call and check if the response is one of the redirect ones (301 gives the same error), and then go ahead and read the contents of the response anyway, making Redirects if AutoRedirect is set to true.

That should be in place already. Can you give me an example of a URL that's giving you this error?

The sample application accesses http://github.com, which does a 302 redirect to https://github.com. That works. The problem might be something else.

That URL doesn't throw an exception for me:
image
This shows the sample application receiving the 302, then forwarding to
https://www.pensionsmyndigheten.se/service/login/login?targetPage=https://www.pensionsmyndigheten.se/service/overview/&failurePage=https://www.pensionsmyndigheten.se/service/login/error/login-failed&cancelPage=https://www.pensionsmyndigheten.se/

What code are you using? Are you using what is in the tip of the master branch in the repository? The try catch that you suggest in your original post is in WebRequestWrapper.cs, line 37.

Thank you for such a quick response!

I have only used the last ”stable” nuget (0.5.79). I will then switch to a preview then, and if that doesn’t work, pick the latest from master.

We have been having issues with CI/CD and publishing to NuGet for some time. (See issue #231 and #237) We have been taking steps to fix it, but the "current" NuGet packages are very old. The newest non-preview version is from February 2016 and the latest preview version is from October 2018. We recently abandoned .NET Framework support for .NET Standard. I'm certain that the .NET Standard SimpleBrowser is not on NuGet.

Thanks for the update, I will follow the nuget update issue!