Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collision with simultaneous hits
Message
De
20/11/2013 00:40:15
 
 
À
19/11/2013 23:23:09
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588296
Message ID:
01588353
Vues:
21
>No, only loHttpWebResponse

Revised version #2:
    ' Get the HTML response from a server
    Public Function GetUrl() As Boolean
        Dim lcHeader As String = ""
        Dim lcUrl As System.Uri = Nothing
        Dim lcValue As String = ""
        Dim llSuccess As Boolean = False
        Dim loHttpWebRequest As System.Net.HttpWebRequest = Nothing
        Dim loObject(2) As Object

        ' 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
            loHttpWebRequest = System.Net.HttpWebRequest.Create(lcUrl)

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

            ' If we have a username
            If cUsername.Length > 0 Then
                loHttpWebRequest.Credentials = New System.Net.NetworkCredential(cUsername, cPassword)
            End If

            ' For each header
            For Each loObject In oHeader

                ' Initialization
                lcHeader = loObject(1)
                lcValue = loObject(2)

                ' Add the header
                loHttpWebRequest.Headers.Add(lcHeader, lcValue)

            Next

            ' Assign the cookie container
            loHttpWebRequest.CookieContainer = oCookieContainer

            Try

                Using loHttpWebResponse As System.Net.HttpWebResponse = loHttpWebRequest.GetResponse()

                    Using loStream As System.IO.Stream = loHttpWebResponse.GetResponseStream()

                        Using loStreamReader As System.IO.StreamReader = New System.IO.StreamReader(loStream)
                            cHTML = loStreamReader.ReadToEnd()
                            llSuccess = True
                        End Using

                    End Using

                End Using

            Catch loError As Exception
                cMessage = loError.Message
            End Try

        Else
            cMessage = cURLCannotBeEmpty
        End If

        ' Reset the values
        cPassword = ""
        cUrl = ""
        cUsername = ""
        nTimeout = 0
        oHeader.Clear()

        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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform