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.


WebClient := WebClient.WebClient();
Stream := WebClient.OpenRead('');

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: Logo

You are commenting using your 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 )

Connecting to %s