What's the easiest way to verify there's an available network connection?

前端 未结 4 632
小蘑菇
小蘑菇 2021-02-04 14:43

I\'m a bit of newbie to c#/.net development, but I\'ve put together a stock tracking application for a small set of assets in my company. I have also set up the database it conn

4条回答
  •  执笔经年
    2021-02-04 15:19

    Some more things to remember:

    • Avaialable Network connection != Available internet connection.
    • Internet Access != access to a specific web site (think proxy filters, or the site could just be down)

    Therefore it's generally best to test for access to the specific resource you need directly.

    These resources are volatile; you have to handle the exception when they go down anyway. So it's generally best to just go get a resource as if you know for sure it exists and put your development time in to making sure your exception handler does a nice job with the failures.

提交回复
热议问题