[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

logging into web sites with VB.NET

Posted on 2008-10-03
6
Medium Priority
?
407 Views
Last Modified: 2012-05-05
I have a web page I am viewing the details of, and I am using the web browser control that comes with visual studio 2008.

However, every time I go to the website I am forced to log in again. I have to reenter the username and password every time (whereas in firefox and ie, a cookie preloads these details for me).

So in two parts:

1) How can I preload this data, can I access the cookie that ie or ff have for this site?, and

2) How can I automate the log in process so that the form is submitted for me with the username and password?
0
Comment
Question by:madivad2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 2

Author Comment

by:madivad2
ID: 22640324
I have increased the points to maximum, I didn't think this would be a hard one to answer... anybody?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 22640396
>>I didn't think this would be a hard one to answer
That is where you are slightly wrong, my friend.  This is not something that gets worked with very much.  It sounds like you need to use is GetElementByID (or something else).

Example:


webBrowser1.Navigate("SomeUrl")
 
While (webBrowser1.ReadyState <> WebBrowserReadyState.Complete) 
  Application.DoEvents();
End While
 
webBrowser1.Document.GetElementById("username").InnerText = "someUsername"
webBrowser1.Document.GetElementById("password").InnerText = "somePassword"
webBrowser1.Document.GetElementById("submit1").InvokeMember("click")
 
While (webBrowser1.ReadyState <> WebBrowserReadyState.Complete) 
   Application.DoEvents();
End While
 
webBrowser1.Document.GetElementByTag("textarea")(0).InnerText = "someText"
webBrowser1.Document.GetElementByTag("input")(3).InvokeMember("click")

Open in new window

0
 
LVL 2

Author Comment

by:madivad2
ID: 22640526
Excellent, almost worked straight off the bat, fixed minor coding (you use a C++/C# do you) there was an alien ';' in there. Also GetElementByTag had to be changed to GetElementsVyTagName. changed the array from 3 to 2 and I was off.

The only two parts I don't get is, what is the 'textarea' bit about?

Also, what is happening with the invoke member on the submit? That didn't work for me, (ie, it didn't login), but it did when the InvokeMember was carried out on the 'input'

Actually, running tests, this has given me the best results:
        wb.Navigate("http://someurl.com")
 
        While (wb.ReadyState <> WebBrowserReadyState.Complete)
            Application.DoEvents()
        End While
 
        wb.Document.GetElementById("username").InnerText = "[madivad]"
        wb.Document.GetElementById("password").InnerText = "[password]"
        wb.Document.GetElementsByTagName("input")(2).InvokeMember("click")

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 22641231
A <textarea> element is a multi-line TextBox.

InvokeMember calls the click method on the <input> element, which is the button.
0
 
LVL 2

Author Closing Comment

by:madivad2
ID: 31502847
with minor amendments, this worked as planned (see code below), thanks o' LearnedOne :-)
0
 
LVL 2

Author Comment

by:madivad2
ID: 22641439
so why didn't the previous one work involving the submit button? That appears (to me) to be more accurate stating the name of the input, being the submit button, otherwise, the array index could be skewed all over the place on a form with many fields
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question