This project has moved and is read-only. For the latest updates, please go here.

FormProcessor Login Problem ASP.NET

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


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("", "//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();

When I run the project(actually a website) it says:    Notice: Undefined index: HTTP_USER_AGENT in /var/www/ on line 88 Warning: Cannot modify header information - headers already sent by (output started at /var/www/ in /var/www/ on line 99Warning: Cannot modify header information - headers already sent by (output started at /var/www/ in /var/www/ 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 ?


Feb 20, 2010 at 5: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.





Feb 20, 2010 at 5: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.