Click here to Skip to main content
15,916,280 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone,
I have a database table which contain usernames and passwords, these credentials are to be used one at a time to login to a website. upon every login i would like to access a page(account page) of the user and read(parse) the HTML.

Improvements:
By Parsing i really mean, i want the response as a String, then i can manipulate the String.
This is a web Based Application, resides on server and clients access it via browser.
i am using sql server 2005 database to store the information which i retrieve from the login.

how can i do this using ASP.NET?, is it is even possible?

[Moved from OP's answer]
I'm not able to code by myself. Been searching for a working example on the net for almost 3 weeks, but didn't find anything. Everyone says it can be done, but no working code at all. No one gives me the answer. Believe me, my hair is becoming gray out of this.
Posted
Updated 7-Dec-11 14:16pm
v6
Comments
Sergey Alexandrovich Kryukov 8-Nov-11 22:29pm    
Please remove unrelated tags ASP.NET, SQL Server.
--SA

It has nothing to do with ASP.NET. You need to use the class System.Net.HttpWebRequest, but to obtain its instance you need to use the class System.Net.WebRequest and its method Create, as the run-time type is defined by the URI.

See:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

Find a code sample for login here: http://stackoverflow.com/questions/450380/login-to-the-page-with-httpwebrequest[^]; HTTPS protocol is used the same way, the code is the same but the root certificate should be registered on the system, see certmgr.msc.

See also:
http://en.wikipedia.org/wiki/Public_key_certificate[^],
http://en.wikipedia.org/wiki/Certificate_authority[^],
http://en.wikipedia.org/wiki/Self-signed_certificate[^] and links from these articles.

Now, parsing of the response…

The ideal case would be if the response provided well-formed XML, which is well supported by .NET parsers. If this is not the case, you can find some HTML parser which does not assume well-formed XML. Try this one:
http://www.majestic12.co.uk/projects/html_parser.php[^], Google for some more.

—SA
 
Share this answer
 
v2
Comments
solutions.software 8-Nov-11 22:33pm    
This is a web based application, can i use the System.Net.HttpRequest?
AswinKrishnan 9-Nov-11 0:44am    
Yes, you can !
Sergey Alexandrovich Kryukov 9-Nov-11 0:47am    
I knew it's Web application, so why would I answer if my solution would not be applicable? This is just irrelevant as you do it in .NET code, server-side in your case. Of course you can. Why would you think it's not?

--SA
below are the steps to take for a successful login:

overview:
this requires a program to simulate what a human does when viewing a site via browser. That is, when you input a site's(login page) into the address bar of the browser and hit enter, you are making a GET request to the server. the server then works with your browser via cookies(commonly) and initiates a session, from then on what ever interactions, get logged via COOKIES.

so:
1)initiate a httpwebrequest and make the method GET and capture the cookie.
2)submit the forms HTTP header( ie. POST METHOD:GET/POST) as defined by the html form and capture the cookie.
3)receive the response as a httpwebrespone and work with the stream as per spec.

this is the basic theory. each step will require certain settings which you need to determine and its different from case to case
 
Share this answer
 
there is a very nice how to video along with code and errything!
http://youtu.be/UV5_b5oaUQk[^]
 
Share this answer
 
Comments
Member 8394855 7-Dec-11 15:58pm    
Thank You very much!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900