Hi, How to let Httpwebresponse ignore the 404 error and continue with it? It's easier than looking for exceptions in input as it is very rare when this happens.
try
{
HttpWebRequest
request
=
(
HttpWebRequest
)
HttpWebRequest
.
Create
(
"http://mysite.com"
);
HttpWebResponse
response
=
(
HttpWebResponse
)
request
.
GetResponse
();
}
catch
(
WebException
ex
)
{
HttpWebResponse
webResponse
=
(
HttpWebResponse
)
ex
.
Response
;
if
(
webResponse
.
StatusCode
==
HttpStatusCode
.
NotFound
)
{
//Handle 404 Error...
}
}
from:http://stackoverflow.com/questions/1857512/httpwebresponse-returns-404-error
转载请注明原文地址: https://ibbs.8miu.com/read-2235504.html