Check Internet Connectivity

When integration to external services in Dynamics NAV, it is sometime nice to know if you are on the Internet.
This can easily be tested using .NET.

Create 2 variables and at Global TryFunction in a Codeunit.

2017-05-26_0750

WebClient := WebClient.WebClient();
Stream := WebClient.OpenRead('https://www.google.com');

Now you call this function from you code and use the boolean result.

Pre NAV 2016 you have to use a Codeunit alone and put the code in OnRun() and use the return from calling the Codeunit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s