FormProcessor Login Problem ASP.NET

Topics: Developer Forum, Project Management Forum, User Forum
Feb 19, 2010 at 3:48 PM

Hello,

I've been trying to use the following code to login to another website USING ASP.NET

string strUserName = "username";
        string strPassword = "pass";

        FormProcessor fp = new FormProcessor();        
        Form form = fp.GetForm("http://www.peopleaggregator.net/login.php", "//form[@name='login_form']", FormQueryModeEnum.Nested);
        form["username"].SetAttributeValue("value", strUserName);
        form["password"].SetAttributeValue("value", strPassword);
        HtmlDocument login = fp.SubmitForm(form);
        //next part used just to show the results in a literal
        StringWriter sw = new StringWriter();
        ConvertTo(login.DocumentNode, sw);        
        Literal1.Text = sw.ToString();
        sw.Flush();
        sw.Close();

When I run the project(actually a website) it says:    Notice: Undefined index: HTTP_USER_AGENT in /var/www/peopleaggregator.net/htdocs/pa/pacore/api/Login/PA_Login.class.php on line 88 Warning: Cannot modify header information - headers already sent by (output started at /var/www/peopleaggregator.net/htdocs/pa/pacore/api/Login/PA_Login.class.php:88) in /var/www/peopleaggregator.net/htdocs/pa/pacore/api/Login/PA_Login.class.php on line 99Warning: Cannot modify header information - headers already sent by (output started at /var/www/peopleaggregator.net/htdocs/pa/pacore/api/Login/PA_Login.class.php:88) in /var/www/peopleaggregator.net/htdocs/pa/pacore/web/dologin.php on line 154

I'm guessing that in a webBrowser thing are different because the webBrowser control is actually a clone of IE

How to do it in ASP.NET ?

Thanks

Feb 20, 2010 at 4:23 AM

I don't use FormProcessor; but, you can use HttpWebRequest, and, HttpWebResponse Objects to perform this Task.

 

Also, are you sure that you are sending all the Post Data that is required?  If you grab a copy of Fiddler, per se, and watch the traffic that goes in/out whilst you log in via IE/FF etc... You can 

verify if you are correctly passing the post data content.

Good luck.

 

Regards,

~K

 

Feb 20, 2010 at 4:27 AM

I just checked that Web_Site out at the page where you are grabbing the Form in question.

 

You are not showing in code here, unless it's abstracted via the FormProcessor, any of the other variables shown in that form 

that are required for logging in with your credentials.

 

So, again, I would suggest grabbing a sniffer tool like Fiddler.  

 

Regards,

~K