1 Replies - 1728 Views - Last Post: 26 June 2013 - 10:45 AM Rate Topic: -----

#1 lysv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-June 13

Application_Error in Global.asax not returning Error line numbers

Posted 25 June 2013 - 10:00 AM

I have a .Net web application where any uncaught exceptions get handled via the Application_Error event in Global.asax. Here, I email myself details of any uncaught exceptions that sneak through.

My problem is that while I am getting the error messages just fine, I am not getting the line numbers in the stack trace to denote where the error is happening.

The Application_Error code is as follows:
    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Error
        ' Fires when an error occurs
        Dim Context As System.Web.HttpContext = HttpContext.Current
        Dim Ex As System.Exception = Context.Server.GetLastError.GetBaseException
        Dim Path As String = Context.Current.Request.Url.AbsolutePath

        Try
            objMailMessage.From = "..." : objMailMessage.To = "..."
            objMailMessage.Subject = "Global Error - " & System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath)
            objMailMessage.Body = Ex.Message & "<BR>" & Ex.Source & "<BR>" & Ex.StackTrace & "<BR>" & Ex.TargetSite.Name
        Finally
            objSmtpMail.Send(objMailMessage)
            objSmtpMail = Nothing
        End Try

        Context.Server.ClearError()
    End Sub



The specific error email I'm getting is:

Input string was not in a correct format.
mscorlib
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Web.UI.WebControls.ImageButton.LoadPostData(String postDataKey, NameValueCollection postCollection) at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
StringToNumber


Of note, I already have the PDB file in the bin folder, as well as have debug set to true in my web.config. Also, this web app was built in Visual Studio 2003, and is running in a .Net 4.0 app pool in IIS 7.5.

Am I doing something wrong in trying to obtain fully detailed error messages, with line numbers, etc? Thanks in advance for any insight you can provide.

Is This A Good Question/Topic? 0
  • +

Replies To: Application_Error in Global.asax not returning Error line numbers

#2 lysv  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 25-June 13

Re: Application_Error in Global.asax not returning Error line numbers

Posted 26 June 2013 - 10:45 AM

To update, as it turns out, the actual problem wasnt really related to exception handling. Apparently there are problems with .Net 4.0 and Internet Explorer 10, specifically with regards to Image Buttons, and I believe javascript as well. I think .Net 2.0 also may have issues.

See: http://connect.micro...button-does-not

Hotfix available here: http://www.microsoft...s.aspx?id=39257

I applied the hotfix on my server about an hour ago, and it appears to no longer be a problem on IE 10 for myself. Will continue to monitor throughought the day to ensure outside IE 10 users dont have problems any more as well.

Will update if there are any further issues.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1