C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet1029/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   1025   1026   1027   1028   1029   1030   1031   1032   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

HttpWebRequest

and


HttpWebResponse

.

Handling Network Errors

Although the program in the preceding section is correct, it is not resilient. Even the 

simplest network error will cause it to end abruptly. Although this isn’t a problem for the 

example programs shown in this chapter, it is something that must be avoided in real-world 

applications. To fully handle all network exceptions that the program might generate, you 

must monitor calls to 

Create( )

,

GetResponse( )

, and 

GetResponseStream( )

. It is important 

to understand that the exceptions that can be generated depend upon the protocol being 

used. The following discussion describes the errors possible when using HTTP.



Exceptions Generated by Create( )

The


Create( )

 method defined by 



WebRequest

 can generate four exceptions. If the protocol 

specified by the URI prefix is not supported, then 

NotSupportedException

 is thrown. If the 

URI format is invalid, 

UriFormatException

 is thrown. If the user does not have the proper 

authorization, a 

System.Security.SecurityException

 will be thrown. 



Create( )

 can also 

throw an 

ArgumentNullException

 if it is called with a null reference, but this is not an 

error generated by networking.

Exceptions Generated by GetReponse( )

A number of errors can occur when obtaining an HTTP response by calling 



GetResponse( )

.

These are represented by the following exceptions: 



InvalidOperationException

,

ProtocolViolationException

,

NotSupportedException

, and 


WebException

. Of these, 

the one of most interest is 

WebException

.

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   1025   1026   1027   1028   1029   1030   1031   1032   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish