Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing three methods
Message
From
20/11/2011 19:18:45
 
 
To
20/11/2011 16:10:32
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01529322
Message ID:
01529330
Views:
34
I combined everything into one method:
        Public cHTML As String = ""
        Public cMessage As String = ""
        Public cPassword As String = ""
        Public cUrl As String = ""
        Public cUsername As String = ""
        Public nTimeout As Integer = 0

        ' Get the HTML response from a server
        Public Function GetUrl() As Boolean
            Dim lcUrl As System.Uri = Nothing
            Dim llSuccess As Boolean = False
            Dim loHTTP As System.Net.HttpWebRequest = Nothing
            Dim loStream As System.IO.Stream = Nothing
            Dim loString As System.IO.StreamReader = Nothing
            Dim loWebResponse As System.Net.WebResponse = Nothing

            ' Reset the values
            cHTML = ""

            ' If we have a URL
            If cUrl.Length > 0 Then

                ' Make it into a Uri
                lcUrl = New System.Uri(cUrl)

                ' Make it into a Web request
                loHTTP = System.Net.HttpWebRequest.Create(lcUrl)

                ' If we have a timeout
                If nTimeout > 0 Then
                    loHTTP.Timeout = nTimeout
                End If

                ' If we have a username
                If cUsername.Length > 0 Then

                    ' Establish the basic authentication
                    loHTTP.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)

                End If

                Try
                    loWebResponse = loHTTP.GetResponse()
                    loStream = loWebResponse.GetResponseStream()
                    loString = New System.IO.StreamReader(loStream)
                    cHTML = loString.ReadToEnd()
                    llSuccess = True
                Catch loError As Exception
                    cMessage = loError.Message
                End Try

            Else
                cMessage = cURLCannotBeEmpty
            End If

            ' Reset the values
            cPassword = ""
            cUrl = ""
            cUsername = ""
            nTimeout = 0

            Return llSuccess
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform