Search:
Namespaces
Discussions
.NET v1.1
Feedback
Custom Error Page Question
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngdebug' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Steven A Smith (VIP)
Does someone have an example of a custom error page that knows both the page
that had the exception AND the details of that exception?
I've seen some examples that use <customErrors> which will redirect with the
original url in the querystring, but no information about the exception that
cause the redirect. I've also seen examples using Application_Error
followed by a redirect. Are these two techniques mutually exclusive? I'm
having trouble even getting Application_Error to fire - does it only occur
depending on the settings of customErrors?
Thanks,
Steve
Reply to this message...
Goldfarb, Christopher
Steven,
I've used Application_Error with no problem. The following code provides
both the page and the exception details (and more). An example of the
output is below as well.
protected void Application_Error(Object sender,
EventArgs
e)
{
//Create an Exception object from the Last error that occurred on
the server
Exception objError = Server.GetLastError();
string strWebsite = "swf.intel.com"; //Name of Web Site or
Application
strError = "APPLICATION: " + strWebsite;
strError += "DATE: " +
DateTime
.Now.ToLongDateString();
strError += "TIME: " +
DateTime
.Now.ToLongTimeString();
strError += "PATH: " + Request.Path;
strError += "SOURCE: " + objError.InnerException.Source;
strError += "FORM: " + Request.Form.ToString();
strError += "QUERYSTRING: " + Request.QueryString.ToString();
strError += "HOST: " +
HttpContext
.Current.Request.ServerVariables["REMOTE_HOST"].ToString();
strError += "PLATFORM: " +
HttpContext
.Current.Request.Browser.Platform;
strError += "BROWSER: " +
HttpContext
.Current.Request.Browser.Type +
" " +
HttpContext
.Current.Request.Browser.Version ;
strError += "COOKIES: " +
HttpContext
.Current.Request.Browser.Cookies.ToString();
strError += "EVENT: " + objError.InnerException.TargetSite;
strError += "MESSAGE: " + objError.InnerException.Message;
strError += "STACK TRACE: " + sStack;
Helper.SendAdmin(strError);
}
Hth,
Chris
-----Original Message-----
From:
Click here to reveal e-mail address
[mailto:
Click here to reveal e-mail address
]
Sent: Sunday, May 19, 2002 10:22 AM
To:
Click here to reveal e-mail address
Subject: SWF Website error
APPLICATION: swf.intel.com
DATE: Sunday, May 19, 2002
TIME: 10:21:56 AM
PATH:
/softwarefactory/development/webserver/src/unhandledexceptiontestharness.asp
x
SOURCE: .Net SqlClient Data Provider
QUERYSTRING:
HOST: 134.134.26.60
PLATFORM: WinNT
BROWSER: IE6 6.0
COOKIES: True
EVENT: Int32 ExecuteNonQuery()
MESSAGE: Line 1: Incorrect syntax near 'dummytable'.
STACK TRACE:
at System.Data.SqlClient.
SqlCommand
.ExecuteNonQuery()
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String
connectionString,
CommandType
commandType, String commandText,
SqlParameter
[] commandParameters)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String
connectionString,
CommandType
commandType, String commandText)
at
Intel.ProcessAutomation.SoftwareFactory.WebServer.BusinessObjects.DAL.Execut
eSQL(String SQL)
in
c:\inetpub\wwwroot\softwarefactory\development\webserver\src\businessobjects
\dal.cs:line 607
at
Intel.ProcessAutomation.SoftwareFactory.WebServer.UnhandledExceptionTestHarn
ess.Page_Load(Object sender,
EventArgs
e)
in
c:\inetpub\wwwroot\softwarefactory\development\webserver\src\UnhandledExcept
ionTestHarness.aspx.cs:line 23
at System.Web.UI.
Control
.OnLoad(
EventArgs
e)
at System.Web.UI.
Control
.LoadRecursive()
at System.Web.UI.
Page
.ProcessRequestMain()
-----Original Message-----
From: Steven A Smith [mailto:
Click here to reveal e-mail address
]
Sent: Saturday, May 18, 2002 1:18 PM
To: aspngdebug
Subject: [aspngdebug] Custom Error
Page
Question
Does someone have an example of a custom error page that knows both the page
that had the exception AND the details of that exception?
I've seen some examples that use <customErrors> which will redirect with the
original url in the querystring, but no information about the exception that
cause the redirect. I've also seen examples using Application_Error
followed by a redirect. Are these two techniques mutually exclusive? I'm
having trouble even getting Application_Error to fire - does it only occur
depending on the settings of customErrors?
Thanks,
Steve
| [aspngdebug] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngdebug.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
System.Data.CommandType
System.Data.SqlClient.SqlCommand
System.Data.SqlClient.SqlParameter
System.DateTime
System.EventArgs
System.Web.HttpContext
System.Web.UI.Control
System.Web.UI.Page
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com