Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to check website response like as website is responding properly like it giving some error
like 404 or 505 or its "Internet Explorer not able to find web page" Please give some different or easy answer i already searched in google..

Iam using Below solution but while using "for loop" for more then one link at a time its not working can any one please help me.

C#
webBrowser1.Url = new Uri( "http://SomeRandomUrl");
            ((SHDocVw.WebBrowser)webBrowser1.ActiveXInstance).NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(Form1_NavigateError);
.
.
.
void Form1_NavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)
        {
            int currentStatusCode = (int)StatusCode;
Posted
Updated 21-Feb-14 22:38pm
v3

1 solution

You can make use of following code:

C#
webBrowser1.Url = new Uri( "http://SomeRandomUrl");
            ((SHDocVw.WebBrowser)webBrowser1.ActiveXInstance).NavigateError += new SHDocVw.DWebBrowserEvents2_NavigateErrorEventHandler(Form1_NavigateError);
.
.
.
void Form1_NavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)
        {
            int currentStatusCode = (int)StatusCode;
        }


Make sure to add reference to Microsoft Internet Controls dll from COM tab.
 
Share this answer
 
Comments
Ashwani Gusain 21-Feb-14 2:01am    
Hi danish thanks for reply but i already use this and the problem is whenever i am using for loop as i have more the one links its not calling to Form1_NavigateError(),can u please give some solution for using for loop also as i have lots of links to check in a loop.
Ashwani Gusain 21-Feb-14 6:23am    
Hi danish please update if it is possible or not?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900