views:

158

answers:

3

I am developing an Asp.Net MVC application that uses Google maps to show Addresses in a map. The problem is that I need to demo the app in an environment not connected to internet. How can I detect with an script that the app is disconnected not to call the Google maps api functions?

+2  A: 

Very similar question to this one. Allen Bargi's answer pointing to the jQuery plugin I think would be the easiest way to detect offline and online, firing an AJAX call to determine whether your MVC application has access to the web.

Another thing you could think about is looking into the Google Gears API which would allow you to work with Google Maps offline. Or so my understanding goes, haven't personally tried it though ... yet :).

Cammy Wan Kenobi
+1  A: 

This should get you there

using System.Net.Sockets;

private void example{ Boolean isConnected; TcpClient tcpClient = new TcpClient(); tcpClient.Connect("maps.google.com", 80); isConnected = tcpClient.Connected; }

AlanPoint45kg
Any where would this code sit? Unless you dump silverlight on the client this is a no go. Remember the client receives html/css and browser is the runtime.
mattcodes
yeah oops. I was apparently in a winforms place that morning.
AlanPoint45kg
A: 

Do you need to do anything this fancy? could you not put a key in the web.config to change when you are in demo mode?

Pharabus