关闭

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

标签: input
1147人阅读 评论(0) 收藏 举报
分类:

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
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:284467次
    • 积分:3942
    • 等级:
    • 排名:第7943名
    • 原创:86篇
    • 转载:161篇
    • 译文:0篇
    • 评论:16条
    文章分类
    最新评论
    技术