views:

78

answers:

3

Im using Google Analytics Dashboard Control which are available at

http://gadashboardcontrols.codeplex.com/

Issue is its working fine when im connected to internet but if im using it on a machine that doesnt have internet access then it shows

Server Error in '/' Application.
The remote name could not be resolved: 'www.google.com' 

I want to catch this exception and shows a friendly message to user. Im calling these dashboard control on my View in an iframe like this

<iframe src="../../GoogleAnalytics/Visitor.aspx" height="275"></iframe>

and if i place try catch in Visitor.aspx page it doesnot catch the exception. How should i catch this exception, Im using asp.net mvc 2 with c#

+1  A: 

You cannot catch this exception because the problem occurs in the browser and not on the server. You do not have control over this from the aspx code.

Pieter
The error in question does indeed occur on the server, but its not catchable as its outside the scope of the calling code.
Moo
Yes, that's what I meant :).
Pieter
A: 

What you can do instead is check network connectivity and serve alternate content in the page if the user is offline. Look into System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() for this.

There's no good way to catch this exception since you're using an iframe and the page is loaded in the browser and not via code. There are some tricks for this, but not as reliable.

Liam
A: 

The error is server-side so should actually try to fix it in your code.

vash47