CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Visual C# 2008 Express Application - open urls, handle cookies and login

    I need some help in Visual C# 2008 Express.
    I don't want you to write the full code , I just need some examples, and help documents.

    The project aim:
    With the application you can login to sites (that using cookies) through a small browser window (system.windows.forms.webbrowser). It is a normal browser. It displays example.com/login .php
    I would like the user to login through this, to get the login cookies.

    Than there is a textbox: user can enter an url
    example.com/add_product.php?name=abcdefg&desc=abcdefghij&price=123
    Than the application only "requests" the url (don't really download and don't displays is)
    But on this part I cant use the browsers cookies , so I cant login.
    I can't login with example.com/login.php?user=admin&pass=something too.
    But I've exported the raw stream and the headers when I login with Firefox (data from HttpAnalyzer *code section)

    I tried HttpWebRequest without and with CookieContainer but I can't get it work.

    Is there any help or examples on this?
    Or is there any way to use the HttpAnalyzer's data?

    Please help me!
    If you can't understand something, I can try to write down it again, because english is not my main language.

    Thank you!


    The HttpAnalyzer export:

    RAW STREAM:
    POST /login.php HTTP/1.1
    Host: example.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; hu; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 (.NET CLR 3.5.30729)
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: hu-hu,hu;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Referer: http://example.com/login.php?url=%2F
    Cookie: __utma=21200424.3377429447400615000.1249065357.1249123348.1249144755.3; __utmz=21200424.1249065357.1.1.utmcsr=anotherdomain.com|utmccn=(referral)|utmcmd=referral|utmcct=/mail/read.fm; __utmb=21200424.1.10.1249144755; __utmc=21200424
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 50

    login=yes&user=admin&password=something


    HEADER::
    (Request-Line):POST /login.php HTTP/1.1
    Host:example.com
    User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; hu; rv:1.9.0.12) Gecko/2009070611 Firefox/3.0.12 (.NET CLR 3.5.30729)
    Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language:hu-hu,hu;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding:gzip,deflate
    Accept-Charset:ISO-8859-2,utf-8;q=0.7,*;q=0.7
    Keep-Alive:300
    Connection:keep-alive
    Referer:http://example.com/login.php?url=%2F
    Cookie:__utma=21200424.3377429447400615000.1249065357.1249123348.1249144755.3; __utmz=21200424.1249065357.1.1.utmcsr=anotherdomain.com|utmccn=(referral)|utmcmd=referral|utmcct=/mail/read.fm; __utmb=21200424.1.10.1249144755; __utmc=21200424
    Content-Type:application/x-www-form-urlencoded
    Content-Length:50

  2. #2
    Join Date
    Jul 2006
    Posts
    297

    Re: Visual C# 2008 Express Application - open urls, handle cookies and login

    Well i don't understand why you use .php extension with a C# website... but i think you need to look for a nice little book on how to build a website with Visual Studio using C#. There are plenty of them out there, i'm sure you can find a free one around somewhere on the internet. They will go over everything you need to know including login, menus, and using a database with your website.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured