Results 1 to 5 of 5

Thread: [2005] WebBrowser component trouble

  1. #1

    Thread Starter
    Junior Member maco's Avatar
    Join Date
    Aug 2006
    Location
    Linköping, Sweden
    Posts
    20

    [2005] WebBrowser component trouble

    Problem: When accessing a certain webpage through Firefox I can logout using this URL : http://www.lunarstorm.se/log/log_exit.aspx, but in Iexplore, it doesn't work, just get send to the mainpage, still being logged in, I need to find out why. I'm making a certain software that would force the logout, but it's using a VB .NET WebBrowser form (based on IE). Anyone know a solution to why the IE webbrowser form acts diffrent from Firefox in these type of cases?

    Note: Doesn't work if I run IE directly either instead of using my software component.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] WebBrowser component trouble

    Could you show us your code? It doesnt sound like it should be doing that.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Junior Member maco's Avatar
    Join Date
    Aug 2006
    Location
    Linköping, Sweden
    Posts
    20

    Re: [2005] WebBrowser component trouble

    I tried doing it through the Original IE and it seems like the site is blocking useing the URL directly more than once in a certain time. Though something in FF allows it. If the user is to click the logoff button on the site it works no matter how many times I log in / log off. So somethins is messed up.

    Here's the code:

    vb Code:
    1. Public Class Form1
    2.     Dim userName As String
    3.     Dim password As String
    4.     Dim count As Double
    5.     Dim counter As Double
    6.     Dim x As Double
    7.     Dim y As Double
    8.  
    9.   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    10.  
    11.         userName = TextBox1.Text
    12.         password = TextBox2.Text
    13.  
    14.         count = TextBox3.Text
    15.         counter = 0
    16.         ProgressBar1.Maximum = count
    17.         countMonitor.Text = counter
    18.  
    19.         While counter < count
    20.  
    21.  
    22.  
    23.             WebBrowser1.Navigate("http://www.lunarstorm.se")
    24.  
    25.  
    26.             Dim start As Integer
    27.             start = My.Computer.Clock.TickCount()
    28.             While My.Computer.Clock.TickCount() - start < 9000
    29.  
    30.                 Application.DoEvents()
    31.  
    32.             End While
    33.  
    34.             counter = counter + 1
    35.             countMonitor.Text = counter
    36.             ProgressBar1.Value = counter
    37.  
    38.  
    39.             WebBrowser1.Navigate("http://www.lunarstorm.se/log/log_exit.aspx")
    40.  
    41.             Dim start2 As Integer
    42.             start2 = My.Computer.Clock.TickCount()
    43.             While My.Computer.Clock.TickCount() - start2 < 7000
    44.  
    45.                 Application.DoEvents()
    46.  
    47.             End While
    48.  
    49.  
    50.         End While
    51.  
    52.     End Sub
    53.  
    54.     Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    55.  
    56.         If WebBrowser1.Url.AbsoluteUri = "http://www.lunarstorm.se/" Then
    57.  
    58.             Try
    59.  
    60.  
    61.                 WebBrowser1.Document.GetElementsByTagName("input").Item(3).InnerText = TextBox1.Text
    62.                 WebBrowser1.Document.GetElementsByTagName("input").Item(4).InnerText = TextBox2.Text
    63.                 WebBrowser1.Navigate("javascript:__doPostBack('ctl07$ctl14$ebLogin$ebLogin_a','')")
    64.  
    65.  
    66.             Catch ex As Exception
    67.  
    68.             End Try
    69.  
    70.         End If
    71.  
    72.  
    73.     End Sub
    74. End class

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] WebBrowser component trouble

    Get rid of these:
    vb Code:
    1. While My.Computer.Clock.TickCount() - start < 9000
    2.  
    3.                 Application.DoEvents()
    4.  
    5.             End While
    You should take advantage of the DocumentCompleted event, navigate to the logout page from there.

    Also, does this really work?
    vb Code:
    1. WebBrowser1.Navigate("javascript:__doPostBack('ctl07$ctl14$ebLogin$ebLogin_a','')")
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Junior Member maco's Avatar
    Join Date
    Aug 2006
    Location
    Linköping, Sweden
    Posts
    20

    Re: [2005] WebBrowser component trouble

    Quote Originally Posted by Atheist
    Get rid of these:
    vb Code:
    1. While My.Computer.Clock.TickCount() - start < 9000
    2.  
    3.                 Application.DoEvents()
    4.  
    5.             End While
    You should take advantage of the DocumentCompleted event, navigate to the logout page from there.

    Also, does this really work?
    vb Code:
    1. WebBrowser1.Navigate("javascript:__doPostBack('ctl07$ctl14$ebLogin$ebLogin_a','')")

    Why should I get rid of them? I'm using the DocumentCompleted to make sure that the page is loaded before logging in, but how would I code so it waits for the page to load again before logging out?


    The javascript navigating thing does work. It uses the javascript that is coded on the website for logging in. The application works all the way, logging in, but it doesn't log out, that's were the problem is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width