david.k.pham

Hey guys!

I have a question about determining what kind of access a program has.

This is the problem - there is an object whose data is populated via a web service (which gets data from the database) or via local access to the database. In the scenario where the application has no web access, I need the program to know that it should use the local access to populate the object.

At this point, this is what is happening:

if httpcontext object is null, then populate object using direct access to db.

else populate object using web service.

Is there any .NET function or whatnot that will allow me to determine what environment (local/network) the program is running in

Thanks!

David Pham



Re: .NET Framework Networking and Communication Determining local or network environment within program

Peter Ritchie

You could PInvoke InternetGetConnectedState. I don't think there's anything specific to just Internet connectivity in .NET. NetworkChange.NetworkAvailabilityChanged event might get raised when Internet connectivity changes; but I haven't verified.