How do I programmatically login to a website

Hi there,

I'm trying to login to a website that uses a login normally stored in the session. I can hit the URL with an https call but I can't seem to find a way to automatically login from my app.

Here is the code I have so far

    try
    {
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        req.Method = method;
        HttpWebResponse res = (HttpWebResponse)req.GetResponse();

        success = (res.StatusCode == HttpStatusCode.OK);
        return res.GetResponseStream();
    }
    catch (UriFormatException ex)
    {
        Console.WriteLine("Invalid URL");
        Console.WriteLine(ex.Message);
    }
    catch (IOException ex)
    {
        Console.WriteLine("Failed connection to URL: {0} with HTTP method: {1}", url, method);
        Console.WriteLine(ex.Message);
    }
Tagged:
Sign In or Register to comment.