Hi ,i am trying to create a program to check my e-mail.It's OK ,but i can't login...
I used fiddler to trace the request which were send from my PC and I receive that:

POST http://www.example.com/login.php HTTP/1.1
Host: www.example.com
Connection: keep-alive
Content-Length: 346
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Origin: http://www.example.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryBcMYlboao244tr1B
Referer: http://www.example.com
Accept-Encoding: gzip,deflate,sdch
Accept-Language: bg-BG,bg;q=0.8
Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3
Cookie: PHPSESSID=3e3e071jt113oijpv1vg47b612; __utma=239560705.1317507043.1363123547.1363123547.1363123547.1; __utmb=239560705.1.10.1363123547; __utmc=239560705; __utmz=239560705.1363123547.1.1.utmcsr=klammlose.weebly.com|utmccn=(referral)|utmcmd=referral|utmcct=/105710401056.html

Content-Disposition: form-data; name="navigation"

Content-Disposition: form-data; name="UserID"

Content-Disposition: form-data; name="Password"


I use that function to send my POST request:

private void defaultPostRequest()
        NameValueCollection l_Content = new NameValueCollection();
        String l_Url = "http://example.com";
        Uri l_Uri = new Uri(l_Url);
        l_Content.Add("username", "user");
        l_Content.Add("password", "pass");
        byte[] l_Response = myWebClient.UploadValues(l_Uri,l_Content);
    catch (Exception e)
        textBoxResponse.Text = e.Message;

But how to upload the boundaries?!?

Thanks in advance,Nikolay

Edited by CrazyMisho

3 Years
Discussion Span
Last Post by JOSheaIV

I presume you're trying to log into a webpage, in which case you will need to send everything that form asks for. See what variables are available on the web form itself and fill each of those in. Make sure you match the variable names EXACTLY. Correct case is probably required.


Ever tried cURl? There's a library for C# that offers all of the great features cURl has (at least I believe). I have really been getting into this for a program I have been developing (and learning how to use it). I am quickly learning it's a powerful tool

Here's a link to get it libcurl for .NET

You could also look into the WebBrowser item, it pretty much an IE browser that you can programmically work with. It allows you to login too, you just have to identify the username, password, and button fields (which can be a trick, I was messing around with this a while back, and while it does work, I am not a huge fan of ... but don't rule it out)

BTW, if you are looking into the cURl, please let me know. I spent a good amount of time figuring out how exactly to get it to work, and feel I have come up with a successful class that will work

Edited by JOSheaIV

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.