There is no bug.  A "System.Net.WebException" is supposed to be thrown
when GetResponse fails which in this case there is no web server on
localhost can handle https.  WebRequest.Create will return a
HttpWebRequest object.  It isn't till it tries to create the streams by 
"GetResponse" that it can tell if it will work.

Maybe the WebException message should match what MS .Net 1.1 gives which
gives a better exception message "The underlying connection was closed;
Unable to connect to the remote server." but beyond the message its
doing the right thing.  A "WebException" is thrown in the right place at
the right time...assuming that your web server can't handle https
requests.



On Mon, 2004-07-12 at 18:26, Harobed wrote:
> Hello, 
> 
> This code get web page from "https://"; URL.
> When I start this code, I've this error :
> 
> Unhandled Exception: System.Net.WebException: Error getting response
> stream: ReceiveFailure ---> System.ObjectDisposedException: The object
> was used after being disposed.
> in <0x00036> Mono.Security.Protocol.Tls.SslClientStream:checkDisposed ()
> in <0x0004f> (wrapper remoting-invoke-with-check)
> Mono.Security.Protocol.Tls.SslClientStream:checkDisposed ()
> in <0x0004d> Mono.Security.Protocol.Tls.SslClientStream:BeginRead
> (byte[],int,int,System.AsyncCallback,object)
> in <0x0007e> System.Net.WebConnection:InitRead (object)
> --- End of inner exception stack trace ---
>  
> in <0x0006e> System.Net.HttpWebRequest:CheckFinalStatus
> (System.Net.WebAsyncResult)
> in <0x00065> (wrapper remoting-invoke-with-check)
> System.Net.HttpWebRequest:CheckFinalStatus (System.Net.WebAsyncResult)
> in <0x001b7> System.Net.HttpWebRequest:EndGetResponse
> (System.IAsyncResult)
> in <0x0006d> System.Net.HttpWebRequest:GetResponse ()
> in <0x000d9> Prog:Main (string[])
> 
> It's one bug, or my code is bad ?
> 
> This code success with "http://"; URL.
> 
> Thanks.
> 
> 
> ----
> 
> using System;
> using System.Net;
> using System.Text;
> using System.IO;
> 
> class Prog 
> {
> 
>       static void Main(string[] args) 
>       {
>               HttpWebRequest WRequest = (HttpWebRequest) 
> WebRequest.Create("https://localhost";);
>               
>               HttpWebResponse WResponse = (HttpWebResponse) WRequest.GetResponse();
>               
>               StreamReader SR = new StreamReader(WResponse.GetResponseStream(), 
> Encoding.ASCII);
>                       
>               try 
>               {
>                       string s = SR.ReadLine();
>                       while (s!=null)
>                       {
>                               Console.WriteLine(s);
>                               s = SR.ReadLine();
>                       }
>               }
>               finally
>               {
>                       SR.Close();
>               }
>       }
> }  
-- 
Tomar <[EMAIL PROTECTED]>

_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to