If on URL then message box - vb.net

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

Related

vb.net if statement on webbrowser control

Morning! (atleast in the US its morning).
I have an app with multiple buttons that load different sites using the webbrowser control. I have the below code to auto login to an email website. However, if I browse to another site and then click the email signin button to execute the below code, it errors out. It errors out because it already signed me in to the site the first time and now since the credentials are cached it logs me right in and bypasses the login page.
How do I check if the login page doesn't exist, then exit sub.
WebBrowser1.Navigate(My.Settings.emailURL)
WaitForPageLoad()
WebBrowser1.Document.GetElementById("user").InnerText = My.Settings.emailUN
WebBrowser1.Document.GetElementById("passwd").InnerText = My.Settings.emailPW
'WebBrowser1.Document.GetElementById("remember_me").SetAttribute("checked", "false")
WebBrowser1.Document.DomDocument.forms(0).submit()
I tried the below but it didn't work:
If WebBrowser1.Navigate(My.Settings.emailURL) <> My.Settings.emailURL
Im assuming it didn't work because its a navigate command
Figured it out. The web address is unique if you're signed in and displays a static web url, so I did a small if statement.
If WebBrowser1.Url.AbsoluteUri.StartsWith(My.Settings.webmailURL)
Exit Sub
Else
Sign in......
end if
Hans thanks for the help, you got me thinking.

Is there a way to detect when the Facebook permissions dialog is shown?

I'm using the FB Javascript SDK, and handling login via a custom button that calls FB.login. Ideally, I'd like to be able to record some tracking data whenever a user is shown the app approval/permissions dialog so that I can see how many users bomb out at this stage. Unfortunately, I can't seem to find a reliable way of achieving this.
If the user is already logged in to FB, I can infer whether it will be shown by checking the login status before calling FB.login. If the user is not_authorized, then I know the permissions dialog will be shown. But if the user is not logged in, my information is more limited. I can assume that the user was shown the dialog if they finish the process as not_authorized, but if they end up being connected then I have no way of distinguishing between a user who was already connected and one who just gave approval.
I'd hoped that the auth.prompt event might help, but it doesn't seem to be fired for the sequence starting from FB.login. Any suggestions?
Ideally, I'd like to be able to record some tracking data whenever a user is shown the app approval/permissions dialog so that I can see how many users bomb out at this stage.
Look at your app insights, there you’ll see Auth Dialog Conversions.
No need for own tracking for that.

VB.NET - Log into website with out website open

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.

Message Box pop up not cleared properly

I have an application in VB.net. I am using the msgbox inside the execution of a loop. Now the message box pops up fine, but when i click on "Ok" in the pop up, the message box
any help will be much appreciated.
I'm guessing that the end of the question is the same as the subject, namely, that in a loop, the message box pops up but when OK is clicked the message box is not "cleared properly".
It sounds like the loop is running tightly enough that the system cannot process any messages and refresh the window.
Without seeing any code, however, this is just speculation and an appropriate solution cannot be given. You might try adding a .Refresh() call after the message box to the form/window or whatever to get the screen to update.
Please provide more information if possible.

Can't retrieve the session on clicking of browser's back button

I have rails application that calculates prices of goods and I set prices in session. I have 'back' button in my application. When I clicks on 'back' link, I will get my previous session values like 'prices','goods' I purchased.
But when I clicks on 'browsers' back button,I won't get my session values, I have to refresh the page for that.
I'd say you have caching issues... The browser remembers what it saw before, and thinks it's the same (without even going to the trouble to ask the server any more). Try if this article helps
You probably want to prevent the browser from caching your pages so that they get refreshed when the user clicks the Back button. This article should help.