You might need to communicate over a secure connection. If you do, chances are that you will be using the Secure Socket Layer (SSL). The example in Listing 26.6 shows you how to make requests using SSL. Listing 26.6 Requesting Data Through SSLtry { WebRequest req = WebRequest.Create( "https://www.SecureServer.com" ); WebResponse result = req.GetResponse(); Stream ReceiveStream = result.GetResponseStream(); Encoding encode = System.Text.Encoding.GetEncoding( "utf-8" ); StreamReader sr = new StreamReader( ReceiveStream, encode ); Char[] ReadBuffer = new Char[256]; int nCount = sr.Read( ReadBuffer, 0, 256 ); while( nCount > 0 ) { String str = new String( ReadBuffer, 0, nCount ); nCount = sr.Read( ReadBuffer, 0, 256 ); } } catch( Exception ) { // Handle the exception here } |