How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
Go Back  Xtreme Visual Basic Talk > > > How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c


Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2010, 11:12 PM
Flying_carlos Flying_carlos is offline
Newcomer
 
Join Date: Oct 2010
Posts: 2
Default How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c


The idea is to make the Login in one Https page through Webrequest/Webresponse and after logged in continue the navigation in a webbrowser control . So ,I got the page using Webrequest/Webresponse with the following code , returning in a structure with a html member where the response is saved:

Code:
    Public Function HttpGet(ByVal url As String, Optional ByVal request As String = "") As Response
        Dim webReq As HttpWebRequest
        Dim webResp As HttpWebResponse
        If request <> "" Then url = url & "?" & request
        Dim ourUri As Uri = New Uri(url)
        HttpGet = New Response
        HttpGet.Success = False
        LastException = Nothing

        ' necesitamos el cookie 
        webReq = CType(WebRequest.Create(ourUri), HttpWebRequest)
        webReq.CookieContainer = _cookieJar
        webReq.Credentials = CredentialCache.DefaultCredentials
        webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET CLR 2.0.50727)"
        webReq.Timeout = timeout
        webReq.Method = "GET"

        ' hacemos el request
        Try
            webResp = webReq.GetResponse
        Catch ex As WebException
            Try
                Debug.Print(Format(Now(), "hh:mm:ss") & " Count = " & ExceptionCount & ex.Message)

                ExceptionCount = ExceptionCount + 1

                If ExceptionCount > 2 Then 'Or ex.Message = "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server." Then
                    LastException = ex
                    HttpGet.Success = False
                    Exit Function
                End If
                HttpGet = HttpGet(url, request)
                Exit Function
            Catch ex1 As Exception
                LastException = ex1
                HttpGet.Success = False
                Exit Function
            End Try
            ' procesar el error
            LastException = ex
            HttpGet.Success = False
            Exit Function
        End Try


        HttpGet.StatusCode = webResp.StatusCode
        If webResp.StatusCode = HttpStatusCode.OK Then
            ' devolvemos el string
            Dim readStream As New StreamReader(webResp.GetResponseStream, System.Text.Encoding.ASCII)
            'Dim result As New StreamReader(webResp.GetResponseStream, System.Text.Encoding.GetEncoding("utf-8"))
            'result.ReadToEnd()
            'HttpGet.StreamResult = result

            HttpGet.Html = readStream.ReadToEnd()
            HttpGet.Success = True
            readStream.Close()
        End If
        webResp.Close()
    End Function


Now I want to display in a WebBrowser control and from here I want to navigate using the WebBrowser control.



I Use the follwing code to do that :


Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
        Dim Resp As Response

        Resp = Login() 'This function call Httpget and return Html in resp

        If Resp.Success Then
            ' Browser.Navigate(New Uri("http://www.access.fda.gov/oaa/index.jsp"))
            Dim Doc As HtmlDocument
            'Dim Brow As New WebBrowser
            Browser.ScriptErrorsSuppressed = True

            Try
                'Doc = Browser.Document
                Browser.AllowNavigation = True

                Browser.Navigate("about:blank")
                If Browser.Document IsNot Nothing Then
                    Browser.Document.Write(String.Empty)
                End If

                Browser.Document.Write(Resp.Html)


            Catch ex As Exception
                MsgBox("Error :" & ex.Message)
            End Try

        End If

    End Sub
The problem is when I click in any button of this page i Get in the screen only the Java command like : "forward?application=ui" but nothing elseCould somebody tell me how is the correct way to handle that?Thanks,Carlos
The problem is when I click in any button of this page I Get in the screen only the Java command like : "forward?application=ui" but nothing else

Could somebody tell me how is the correct way to handle that?

Thanks,



Carlos

Last edited by Flyguy; 10-25-2010 at 01:53 AM. Reason: added [code]..[/code] tags
Reply With Quote
Reply

Tags
login, navigation, webbrowser, webrequest


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
 
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
How to use Webbrowser to display a page obtained it with Webrequest/webresponse and c
 
-->