473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

global.asax: Application_Error how to get informations about the exception

Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {

}

thanks for help
John
Nov 19 '05 #1
3 2432
Yes..

You can write for ex,

protected void Application_Error(Object sender, System.EventArgs e)
{
System.Web.HttpContext context = HttpContext.Current;
System.Exception e= Context.Server.GetLastError();

LogError(e); //Your own logging function...

context.Server.ClearError();

Response.Redirect("some_error_occured_we_are_sorry .aspx");

}

Hope this helps

-Rajesh
http://www.sharpVoice.com
"John Holgerson" <do**********@web.de> wrote in message
news:f9**************************@posting.google.c om...
Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {

}

thanks for help
John

Nov 19 '05 #2
We recently discussed this:

http://groups-beta.google.com/group/...ff7fc1db95c1c7

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {
}

thanks for help
John


Nov 19 '05 #3
Hi John,

You can try the foolowing code snippet to do the same:

<%@ Application Language="C#" %>
<%@ Import Namespace="System.Diagnostics" %>

<script language="C#" runat="server">
void Application_Error(object sender, EventArgs e)
{

Exception ex = Server.GetLastError().GetBaseException();

EventLog.WriteEntry("Test Web",
"MESSAGE: " + ex.Message +
"\nSOURCE: " + ex.Source +
"\nFORM: " + Request.Form.ToString() +
"\nQUERYSTRING: " + Request.QueryString.ToString() +
"\nTARGETSITE: " + ex.TargetSite +
"\nSTACKTRACE: " + ex.StackTrace,
EventLogEntryType.Error);
}
</script>

HTH

Mona[Grapecity]

"John Holgerson" <do**********@web.de> wrote in message
news:f9**************************@posting.google.c om...
Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {

}

thanks for help
John

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JP | last post by:
I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event...
5
by: vbMental | last post by:
I am deep into a project and cannot get this to work correctly. I am trying to make a custom error page that will be able to know what exception occurred. I already know about the defaultRedirect...
14
by: paul downing via DotNetMonster.com | last post by:
global file email send -------------------------------------------------------------------------------- guys, i'm developing an application and want to send an email with an error if it occurs...
7
by: Jonas | last post by:
Hi! I have an Application_Error method in global.asax that uses Server.Transfer to move execution to a custom error page. This works fine when an exception is thrown in one of the aspx or ascx...
2
by: tshad | last post by:
I have my error handling set up in Global.asax: Sub Application_Error(Sender As Object, E as EventArgs) In this procedure I call a function in a dll that will write out to a history file. ...
1
by: Anonieko | last post by:
Global.asax? Use HttpModules Instead! In a previous post, I talked about HttpHandlers - an underused but incredibly useful feature of ASP.NET. Today I want to talk about HttpModules, which are...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
1
by: paulo | last post by:
Hello, I have a DLL library containing some web services which are declared in each .asmx file in the following way: <%@ WebService Language="C#" Class="LibraryName.WebService" %> I would...
1
by: jobs | last post by:
I'm forcing an error/exception in one page as follows Protected Overrides Sub OnLoad(ByVal e As EventArgs) Dim badthing As New Exception("XXX") Throw badthing End Sub And attempting to set...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.