How to post to a sign-in form with Flurl

618 Views Asked by At

I want to represent a signin in a url(i.e. eclass.aueb.gr) to get the source code of the next page(the portfolio of the user). What i have now, is the code from documentation...

var response = await "https://eclass.aueb.gr/index.php".PostUrlEncodedAsync(new
            {
                uname = "name",
                pass = "pass"
            });

Currently the response is the code of the url itself.

1

There are 1 best solutions below

1
On

The page is most likely following the PRG pattern (as it should, per best practices), so the fact that the response you are getting is the original page just means you didn't code the redirect part. Do you need to? Not if all you need to do is log in. Are you successfully logged in? Hard to say for certain. response.StatusCode might be "Unauthorized" (401) if it failed (you could test it against invalid credentials), but since you're scraping a site designed for browsers and not automation (like an API), you might have to pick through that big string of HTML you got back and look for error messages. There again, see what happens in a browser when you try to log in with invalid credentials. And remember - Chrome DevTools are your friend, particularly the Network tab in this case.