Initial import
This commit is contained in:
parent
0c865416ca
commit
04804b89a9
279 changed files with 12945 additions and 0 deletions
35
web/errors/CustomErrorPages/CustomErrors4/ErrorModule.cs
Normal file
35
web/errors/CustomErrorPages/CustomErrors4/ErrorModule.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace AspNetResources.CustomErrors4
|
||||
{
|
||||
public class MyErrorModule : IHttpModule
|
||||
{
|
||||
public void Init (HttpApplication app)
|
||||
{
|
||||
app.Error += new System.EventHandler (OnError);
|
||||
}
|
||||
|
||||
public void OnError (object obj, EventArgs args)
|
||||
{
|
||||
// At this point we have information about the error
|
||||
HttpContext ctx = HttpContext.Current;
|
||||
|
||||
Exception exception = ctx.Server.GetLastError ();
|
||||
|
||||
string errorInfo = "<br>Offending URL: " + ctx.Request.Url.ToString () +
|
||||
"<br>Source: " + exception.Source +
|
||||
"<br>Message: " + exception.Message +
|
||||
"<br>Stack trace: " + exception.StackTrace;
|
||||
|
||||
ctx.Response.Write (errorInfo);
|
||||
|
||||
// --------------------------------------------------
|
||||
// To let the page finish running we clear the error
|
||||
// --------------------------------------------------
|
||||
//ctx.Server.ClearError ();
|
||||
}
|
||||
|
||||
public void Dispose () {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue