You have used the webbrowser control. Haha. It can provide us with a lot of convenient operations.
However, if the computer cannot access the Internet or the network speed is slow, it will not be a great deal if there is an interface that cannot find the server. Haha. At least I think so.
What should we do? Check the network connection.
If (! Start. checkconnect ())
{
This. axwebbrowser1.navigate ("about: <style> frame, HTML, body {margin: 0px; padding: 0px ;} </style> <br> <Div style = 'color: red; font-size: 20px; font-weight: bolder; text-align: center; 'valign = 'center'> You must connect to the Internet to use this function. </Div> <br> <center> <a href = 'wy: // refresh (); 'style = 'text-align: center; font-size: 12px; color: Blue; cursor: hand; '> retry </a> </center> ", ref arg2, ref arg2, ref arg3, ref arg4 );
Return;
}
Checkconnect is a function that checks whether it is connected to the Internet. Its core function is to use the system. net. DNS. Resolve static class for detection.
Public static bool checkconnect ()
{
Bool B = true;
Try
{
Iphostentry IPS = system. net. DNS. Resolve ("www.5inet.net ");
B = true;
}
Catch (exception ex)
{
B = false;
Console. writeline (ex. tostring ());
}
Return B;
}
If the check fails, navigate webbrowser to about: add your error message to the end. It's easy.