VB.NET - Log into website with out website open - vb.net

I want to create a program to fetch information from a website (that's fine). However, you need to be logged in to get this information.
I just want two simple textbox controls that I would type my username and password into and hit submit and the information would be returned to me so I can use it. (I don't want to use a webbrowser control)
Sorry if I wasn't clear
And also
(this really isn't important, but its up to you if you want to answer, it's probably hard)
How would I go about checking if I am still logged into a website or not (as in TRUE or FALSE)

you can pass credentials into a HttpWebRequest object.

You could use a webbrowser control since it is easy, and just set its display to not visible - the user would never see anything. You could still interact with the page just like normal. You could use the same control to log yourself out by clicking on the logout button. You would set everything up and test it with visible=true, and when it all works, set visible to false.

Related

Webbrowser control cannot display page

Unless I am missing a step, I have done the following:
Drag webbrowser control onto form (WebBrowser1)
Drag button onto form
For button click action I did
WebBrowser1.Navigate("http://www.google.com")
and I get "cannot display the page"
It does this with whatever URL I use, whether I put http first or not.
Any idea what could be causing this? Could it be some type of security restriction on my machine or network that prevents non-browsers from accessing the internet?
It's a security setting on my machine preventing it. Thanks all.

How to stop webbrowser control refreshing when server requests it

I have a webbrowser control that points at a webpage that holds some fields that change quickly. When these fields change the server seems to request that the webpage refreshes. This poses a problem if programatically interact with the webbroswer. Is there anyway to force the webbrowser to not refresh? No real code to show. since I'm hoping this is a one line property I can create/add.
Maybe you are looking for the WebBrowser.Stop() Method (MSDN)

If on URL then message box

So I have this weird problem. I have a WebBrowser starting on the page https://live.xbox.com/en-US/MyXbox/GamerProfile (It is a page for editing information on your account) but whenever it goes there it takes the user to live.com to log in, and then goes back to the page to edit his profile. This is how I want it to function, but I want a message box to display if it takes the user to the page again (to verify he's logged in). This is what I have so far:
If WebBrowser1.Url.OriginalString() = "https://live.xbox.com/en-US/MyXbox/GamerProfile" Then
MessageBox.Show("You are logged in!")
End If
But I never get the message box to show, and I don't think it works :\
Does anyone know why it isn't working?
which part of your application is that code running? I mean, does your program knows when xbox takes the webrowser to the login page and back? If your code only run once when the webbrowser object is created, then this doesn't get run.
EDIT:
In that case, the code should be within the WebBrwoser.DocumentCompleted() event. Take a look at this: http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documentcompleted.aspx

VB.Net button open multiple user and auto login in different window of IE

I have a website stored 100 users ....now i want to create a VB form with 100 buttons ....while i click button1, it will open IE then log in users1 automatic and when i click button2 , it will open IE then log in as user2 automatic. user3 until user100 the same ....click from button on vb form.
Note : i am already done to set open IE and log in as different users in each windows but now i am finding how to set auto log in with different users in the same website when i click each button in form.
i have something more about form....i will use ( 100 button click = 100 users = 100 IE window ....)
it depend on user click on button that he need to log in......because we don't know that what button/users/time will he want to click .....
I really need your help urgently...
Thank in advanced.
here is some code of Button_Click
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using p As New Process
p.StartInfo.FileName = "C:\Program Files\Internet Explorer\iexplore.exe"
p.StartInfo.Arguments = "http://test.com"
p.Start()
End Using
This is the only way I can come up with on how to solve this.
My guess is that your login is using POST variables, it's pretty much standard.
To make this work you would have to allow the username and password to be supplied with GET. That is, sending them in the url like this:
http://test.com/login.php/asp?username=username&password=password
Since you haven't specified whether you use PHP or ASP.NET I will add info on how to get the value for both:
ASP.NET
Request.Querystring("username")
PHP
$_GET["username"];
EDIT based on comment
You are correct it is not possible to isolate separate webbrowser controls.
I would suggest you look into either WaTin to control separate IE instances, or Awsomium .NET, which i believe allows separate sessions in 1.7, though i haven't tested it.
Also be aware that since IE8 session cookies are shared across instanced by default, so you would need to run them with the -nomerge flag. WaTin supports this.
Based on the fact that you have not mentioned this in your question, i am presuming you are using IE7. If that is the case, and this application is not intended to be used on other machines, it should be possible to create a separate application with an embeded webbrowser control, then launch multiple insatances of that application from the main one, so you can add your own communication mechanism, but WaTin is probably a far better idea
OLD ANSWER:
It is very hard to work out what you want to do, but im guessing you want to create a winforms app, that lets you to choose a user account, and then open a browser and login to a website with that account.
Based on that assumption, my suggestion would be to have one button, and some way of selecting the account, say a comboBox, and a webbrowser control:
http://img198.imageshack.us/img198/888/66649645.jpg
Rather than 1 button per user account and trying to manipulate an external browser.
If this is indeed what you want to do, comment and i will edit my answer as required, and provide starting code if you need, but i cant do that without really undertanding what you need to do.

How to come back to form without reset the values?

I have a web application that is made with Java+Struts.
There is a form that when is submited it executes an Action that shows the results of the search.
Since here, all ok.
What I need is to put a link in the results page to come back to the form without erasing the search parameters.
I've put a link that goes back to the form page, but allways erase the search parameters.
I've thinking about saving and restoring this parameters to the java session, or adding the parameters to the url (like: /myForm?param1=1&param2=2&param3=3) but I think that maybe there is a better way to do this.
There is any way to do this with struts?
Pd. The struts version is 1.3.8
Just add the parameters (/myForm?param1=1&param2=2&param3=3) to the button url that leads back to the search form. Then populate the fields using the parameters. No need to use session variables.
Unless i'm missing something...