HttpWebResponse returns 404 error(解决异常后读取后续数据的问题)

    技术2022-07-05  175

    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

    最新回复(0)