.


:




:

































 

 

 

 


WebExceptionStatus , .




 

CacheEntryNotFound

 

ConnectFailure

 

ConnectionClosed

 

KeepAliveFailure

 

MessageLengthLimitExceeded

 

NameResolutionFailure

 

Pending

 

PipelineFailure

 

ProtocolError

 

ProxyNameResolutionFailure

 

ReceiveFailure

 

RequestCanceled

 

RequestProhibitedByCachePolicy

 

RequestProhibitedByProxy

 

SecureChannelFailure

 

SendFailure

 

ServerProtocolViolation

 

Success

 

Timeout

 

TrustFailure

 

UnknownError

 

, .

 

, GetResponseStream ()

HTTP GetResponseStream () WebResponse ProtocolViolationException, , . GetResponseStream (), , . ObjectDisposedException , . IOException, , , , .

, , .

// .

Using System; using System.Net; using System.10;

class NetExcDemo { static void Main() { int ch;

try {

// WebRequest URI. HttpWebRequest req = (HttpWebRequest)

WebRequest.Create (" http://www.McGraw-Hill.com ");

// . HttpWebResponse resp = (HttpWebResponse) req.GetResponse ();

// .

Stream istrm = resp.GetResponseStream();

/* ,

URI. 400 . <ENTER>, , 400 . */ for(int i=l;; i++) { ch = istrm.ReadByte(); if(ch == -1) break;

Console.Write ((char) ch); if((i % 4 0 0)==0) {

Console.Write (" <Enter>.");

Console.ReadLine();

}

}

// . // istrm. resp.Close ();

} catch(WebException exc) {

Console.WriteLine (" : " + exc.Message +

"\ : " + exc.Status);

} catch(ProtocolViolationException exc) {

Console.WriteLine(" : " + exc.Message);

} catch(UriFormatException exc) {

Console.WriteLine(" URI: " + exc.Message);

} catch(NotSupportedException exc) {

Console.WriteLine(" : " + exc.Message);

} catch(IOException exc) {

Console.WriteLine(" -: " + exc.Message);

} catch(System.Security.SecurityException exc) {

Console.WriteLine(" : " + exc.Message);

} catch(InvalidOperationException exc) {

Console.WriteLine(" : " + exc.Message);

}

}

}

, . , Create () :

WebRequest.Create(" http://www.McGraw-Hill.com/moonrocket ");

, .

: : (404) .

: ProtocolError

- www.McGraw-Hill. com moonrocket, URI, .





:


: 2016-12-03; !; : 399 |


:

:

- , - .
==> ...

1430 - | 1359 -


© 2015-2024 lektsii.org - -

: 0.013 .