question

TomG avatar image
TomG asked

Report Manager: ASP.NET Error Notifications

Can I get Report Manager (2005) to email me details of any ASP.NET exceptions/errors? I have seen suggestions for modifying the Global.asax file for ASP.NET projects but none of these seem to work for me and was hoping someone here had implemented a SQL Server specific solution!
ssrs-2005error-handlingasp.net
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image
Fatherjack answered
If the error is logged in the ReportServer database then you could create a SQL Agent job to run every few minute and check for the error and then email you results if found. I would suggest that you create a way of checking when the last check was executed so that you dont scan the whole database every time the job runs. I am not sure how you would identify the error you want in particular though. I just ran USE [ReportServer] go SELECT DISTINCT [el].[Status] FROM [dbo].[ExecutionLog] AS el and only found a Status that indicated a failure of 'rsInternalError', there may be others that I don't have on this server though.
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

TomG avatar image TomG commented ·
Because it's at the Web Application level it doesn't end up in the ReportServer database. It's things like the Excel rendering failing. The report shows up as rsSuccess or somesuch in dbo.ReportServer but the user sees an ASP.NET error page with stack trace.
0 Likes 0 ·
Fatherjack avatar image Fatherjack ♦♦ commented ·
then I guess, as you are 2005, the web server log files may offer something. Have you looked in IIS?
0 Likes 0 ·
TomG avatar image TomG commented ·
I can check log files and even event logger on Server has some info but I was really hoping for some sort of email notification which includes the stack trace etc. I know this is generally possible with ASP.NET applications but it's beyond my know-how to get it working in Report Manager. Thank you for taking the time to answer.
0 Likes 0 ·
Fatherjack avatar image Fatherjack ♦♦ commented ·
If you know its possible then I'd suggest tracking down some ASP forum to find out how others have achieved it. I can see a way of doing it with importing the data from the log files and then running a report on the data but I fear it wouldnt be as elegant as a .Net solution. Good luck
0 Likes 0 ·
Kevin Feasel avatar image
Kevin Feasel answered
In the Global.asax, there is an Application_Error event which gets triggered whenever an unhandled exception bubbles up to the top without being caught by any other functions (so, on a website, that'd be a case where you get the yellow error page). If the code is trapping exceptions at a lower level and displaying text (which good code should be doing), you can't really use that event to capture an error. For our developers' code, we log the exceptions in a database and fire off e-mails. In their code, they do this in try-catch blocks, but there's a catch-all Application_Error that looks a little bit like: protected void Application_Error(object sender, EventArgs e) { ExceptionChit chit = null; Boolean UrlNotFoundException = false; Exception ex = HttpContext.Current.Server.GetLastError().GetBaseException(); try { if (ex is HttpException) { HttpException hex = (HttpException)ex; if (hex.GetHttpCode() == 404) UrlNotFoundException = true; } if (!UrlNotFoundException) { //This logs the exception and sends out the relevant e-mail. chit = ExceptionChit.LogException(ex, Request, "Application", "Username"); } Server.ClearError(); } finally { if (UrlNotFoundException) { Response.Redirect("~/ Default.aspx"); } else { //Do some other stuff that I've taken out from here. } } } The exception chit code saves a record in a table, and then you could have a SQL Agent job run every few minutes or so to send out e-mails. ex (the exception) contains properties like Message and StackTrace, so you could put them directly into the table. The stack trace can get pretty long, though, so you may want to think about maintenance with that table if you have a lot of exceptions. I believe you would need to be able to re-compile the code before Global.asax changes take effect. I haven't messed with the Report Manager code, so I don't even know if you can compile it yourself.
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image Fatherjack ♦♦ commented ·
Kevin - wouldn't a simple stop//start of the reporting services website cause it to recompile?
0 Likes 0 ·
KenJ avatar image KenJ commented ·
Whenever you change the global.asax file, the site recompiles. No restart required. Here is an overview of dynamic compilation - http://msdn.microsoft.com/en-us/library/ms366723(v=vs.90).aspx
0 Likes 0 ·
Kevin Feasel avatar image Kevin Feasel commented ·
I've always re-built and re-deployed web application projects, so to be honest, I didn't even know that you could change the Global.asax on the fly like that.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.