Question httpWebRequest & proxy problem

gerardo79

New member
Joined
Oct 13, 2011
Messages
4
Programming Experience
1-3
Hi,

I am using httpWebRequest to read the content of a url through a proxy server. Since I didn't want to configure the proxy in my application I read whatever I had in the IE, but it seems to take forever to actually read the url (less than 1kb).

Here is the code that I am using. Is there anything you see that I am doing wrong?

    Private Function EnviarAQsp(ByVal strUrl As String, ByVal cookieToProvide As String) As String
        Dim req As System.Net.HttpWebRequest
        Dim res As System.Net.HttpWebResponse
        Dim sr As System.IO.StreamReader


        req = System.Net.WebRequest.Create(strUrl)
        req.Proxy = WebProxy.GetDefaultProxy
        req.Proxy.Credentials = CredentialCache.DefaultCredentials


        'set the standard header information 
        req.Accept = "*/*"
        req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)"
        req.ContentType = "application/x-www-form-urlencoded"
        req.AllowAutoRedirect = False
        req.Headers.Add(HttpRequestHeader.Cookie, cookieToProvide)
        res = req.GetResponse()


        'read in the page 
        sr = New System.IO.StreamReader(res.GetResponseStream())
        Dim strResponse As String = sr.ReadToEnd


        Return strResponse


    End Function


Thank you very much.
 
Top Bottom