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#
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.
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.
The error is server-side so should actually try to fix it in your code.
Related
I am using HtmlAgilityPack to perform Scraping in C # Asp.Net, so far I have not had problems when doing Scratch from several web, however, trying to eject the following code I get an error
Var getHtmlWeb = new HtmlWeb ();
Var home page = getHtmlWeb.Load ("https://www.corfo.cl/sites/cpp/home");
The error that appears is:
"Connection terminated: Unexpected sending error."
The only web that is giving me problems is Corfo and not how to solve this.
I appreciate your help
This site relies on cookie to work, e.g. one of the URL it requested is
https://www.corfo.cl/sites/Satellite;jsessionid=T8w78ZolfWgr3ZoEBBvE81nBiXbXIdjfF1In3bgpZiYvL_w8TF4p!1081543155!-596930586?c=Page&cid=1456408322328&pagename=CorfoPortalPublico/Page/corfoListadoOfertaInteligenteWebLayout
So, when you request www.corfo.cl, first it forward to www.corfo.cl/sites/cpp/home, then on /sites/ folder, it set cookie jsessionid=OHS_1~T8w78ZolfWgr3ZoEBBvE81nBiXbXIdjfF1In3bgpZiYvL_w8TF4p!1081543155!-596930586 etc.
With this cookie, this page build itself with all/some components related with this jsessionid.
If client code doesn't handle these logic, as above two lines, the server reset the connection as expected, because server doesn't know how to build this page without jsessionid.
The inner exception from System.Net.WebException is
{"Authentication failed because the remote party has closed the transport stream."}
Hope this helps!
Hi I develop an UWP app that communicate with html page via Javascript send message app by using document.location.(document.location = "toApp://PEtPTVVU....") and i catch it with webview UnsupportedUriSchemeIdentified event .But problem is when i use a string more than 260 it gives error threw an exception of type System.UriFormatException` .Is there any solution beside a kind of link shortener
Solution for me
I used alert in html and catch encoded message like that
I have a WPF application where I am loading and streaming videos for training purposes. Currently it works when I use an internal server (IIS). However because of the strain it is putting on local resources we are trying to leverage our Azure account, which has CDN services included.
My thought was that I could switch out the url from
source = new Uri(#"http://192.168.1.2/videos/NewCoupons.wmv", UriKind.Absolute);
to
source = new Uri(#"https://myazurespace.blob.core.windows.net/asset-8e1-snip-04%3A25Z", UriKind.Absolute);
I cut the Azure link down ( -snip- ) because it is way to long to be readable and is not relevant for this question. If I cut and past the link into my browser the browser will prompt to play the video so I know the link is good. However when I try to run it from my WPF I get a {"Object reference not set to an instance of an object."} System.NullReferenceException error right on the exception catch below.
private void PlayButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (mediaElement.Source != null)
mediaElement.Play();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.ToString());
}
}
So do I have to do something different in my code to use media from an external CDN? By the way I did cut and paste the link in the exception to the browser to make sure something wasn't getting malformed on its way there and it did pull the video from Azure correctly.
Seems to be a known bug that the WPF team doesn't want to fix. WPF MediaElement throws a NullReferenceException for HTTPS URLs. Your local version should fail too with HTTPS. Since the bug is set to Won't Fix, your best bet might be to just use an HTTP URL. Link to official bug page: connect.microsoft.com/VisualStudio/feedback/details/934355/
Per comments, you'll need to update the URI for your video stream to use HTTP.
I've a question. In a web site created in asp.net with vb.net in code behind, how I can show message of exceptions from methods in app_codevb folder.
Example a method return a table with a list of customers, but occurs a error of timeout or error in sintax.
How I can show the user in the form the error occurred in app_codevb folder?
If you don't do anything then it will automatically show any unhandled errors on the page.
Somewhat in this format
Server Error in '/WebApp' Application.
Error Message...
Description: ...
Exception Details: ...
Source Error: ...
Source File: ...
Stack Trace: ...
Version Information: ...
However, it is not a good thing. It looks ugly and breaks your site. It also shows your immaturity in programming besides opening your site for attacks. The better way is to use Try... Catch blocks where there is a possibility of errors occurring in your application and handle the error appropriately.
I have created a simple app which will do some calcualtions when user input some values.The app is working properly but when user forget to input some values in a textbox and run the app; the app stops working and it hangs. I want to know is there any simple error handling script for windows phone sdk.
I have used this error handiling script before in visual basic and in their its work perfectely.
On Error GoTo error_handler
Dim one,two ....
//some codes
.
.
......
error_handler:
Textblock1.Text = "Error"
I tried to use this above script in sdk but its showing this error
Requested operation is not available because the runtime library function 'Microsoft.VisualBasic.CompilerServices.ProjectData.CreateProjectError' is not defined.
As i asked in the question i was looking for a simple error handling script. I have found "accidently" the error handling script using try and catch method.Below is the code i used for error handiling.
Try
// Your code for app
Catch ex As Exception
MessageBox.Show(ex.Message.ToString(), "Error!", MessageBoxButton.OK)
End Try