Re: System.Net.WebException
From: Adrian D. Garcia (garcia.adrian_at_gmail.com)
Date: 09/15/04
- Next message: Chris Lyon [MSFT]: "Re: Garbage Collection Object Promotion"
- Previous message: Anonynona: "RE: Print a big bitmap"
- In reply to: Feroze [msft]: "Re: System.Net.WebException"
- Next in thread: Adrian D. Garcia: "Re: System.Net.WebException"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 15 Sep 2004 14:25:24 -0700
Thanks for the replay,
My network hasnt a proxy buy I m working with the idea....
Where I can configure the default proxy to the stack that .NET use to
connect to HTTP? The machine is a Windows XP Prof. with SP1. I was traiyng
with proxycfg but without luck.
Also I m looking at machine.config, at the systen.net section.
Why do you think that the ASP.NET app can connect and the conolse/windforns
apps dont? Wich are the difference between this type of app?
Thanks in advance
-- Adrian D. Garcia MCSD NDSoft Consultoria y Desarrollo "Feroze [msft]" <ferozed@online.microsoft.com> wrote in message news:41471fe9$1@news.microsoft.com... > From the stack, it looks as if the app is trying to connect through proxy > and failing, > > does your network have a http proxy that you need to use ? if so, set the > proxy address in a WebProxy instance, and set the "proxy" property of the > HttpWebRequest object. > > -- > feroze > > ----------------- > This posting is provided as-is. It offers no warranties and assigns no > rights. > > See http://weblogs.asp.net/feroze_daud for System.Net related posts. > ---------------- > > "Adrian D. Garcia" <garcia.adrian@gmail.com> wrote in message > news:eoF90MQmEHA.3544@TK2MSFTNGP15.phx.gbl... > > Hi, > > I m trying to connect to a HTTP Server using the HTTPWebRequest Class but > > I'm getting the following error: > > > > System.Net.WebException: The underlying connection was closed: Unable to > > connect to the remote server. ---> System.Net.WebException: The underlying > > connection was closed: Unable to connect to the remote server. > > at System.Net.HttpWebRequest.CheckFinalStatus() > > at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) > > at System.Net.HttpWebRequest.GetResponse() > > at System.Net.Connection.TunnelThroughProxy(Uri proxy, HttpWebRequest > > originalRequest, Socket& socket) > > --- End of inner exception stack trace --- > > at System.Net.HttpWebRequest.CheckFinalStatus() > > at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) > > at System.Net.HttpWebRequest.GetResponse() > > at Proceso.Proceso.MiRequest(String Method, String URL, String > > DataToPost, NameValueCollection RequestHeaders, NameValueCollection& > > ResponseHeaders, String URLReferer, String ContentType, String& > ResponseURL) > > in E:\_TF\Proceso.vb:line 67 > > > > Here is the code that generate the problem: > > > > > > > > Public Function MiRequest(ByVal Method As String, ByVal URL As String > > String, ByVal ContentType As String) As String > > > > Dim i As Integer > > > > Dim res As HttpWebResponse > > > > Dim req As HttpWebRequest > > > > Dim RequestStream As Stream > > > > Dim ReceiveStream As Stream > > > > Dim encode As Encoding > > > > Dim sr As StreamReader > > > > req = WebRequest.Create(URL) > > > > req.Method = Method > > > > 'req.Timeout = 12000 > > > > req.KeepAlive = False > > > > > > > > req.ContentType = ContentType > > > > Dim SomeBytes() As Byte > > > > Dim UrlEncoded As New StringBuilder > > > > Dim reserved() As Char = {ChrW(63), ChrW(61), ChrW(38)} > > > > > > > > res = req.GetResponse() > > > > ReceiveStream = res.GetResponseStream() > > > > encode = System.Text.Encoding.GetEncoding("utf-8") > > > > sr = New StreamReader(ReceiveStream, encode) > > > > Dim read(256) As Char > > > > Dim count As Integer = sr.Read(read, 0, 256) > > > > Dim buffer As New System.Text.StringBuilder(1000) > > > > Do While count > 0 > > > > buffer.Append(read, 0, count) > > > > count = sr.Read(read, 0, 256) > > > > Loop > > > > res.Close() > > > > Return buffer.ToString() > > > > End Function > > > > > > > > As you can see I m using the KeepAlive property to False. (KB Suggestion). > > > > This code works fine inside an ASP.NET page but always generate the prvius > > error when I used inside a Console App or Windows Form App. > > > > The O.S. is Windows XP with SP 1 with Framework 1.1 installed. > > > > Any idea why its works inside an ASP.NET process but not in other process? > > > > Regards. > > > > Adrian > > > > > > > > > > -- > > Saludos > > Adrian D. Garcia > > MCSD > > NDSoft Consultoria y Desarrollo > > > > > >
- Next message: Chris Lyon [MSFT]: "Re: Garbage Collection Object Promotion"
- Previous message: Anonynona: "RE: Print a big bitmap"
- In reply to: Feroze [msft]: "Re: System.Net.WebException"
- Next in thread: Adrian D. Garcia: "Re: System.Net.WebException"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|