For example : Error should be throw from page, only then you can track here, instand of if you are handled in page using try..catch block. Those error will not be considered.
Code : In your Page :
Try this
try
{
/// your code...
}
catch(Expection ex)
{
throw;
}
Please mark the replies as answers if they help. -Good Luck
Kiruba.
ProgrammingP...
0 Points
2 Posts
Error Event not being called in HttpModule
Oct 30, 2011 07:55 AM|LINK
Hi
I have create below HttpModule that will catch exceptions in the Web Appllication:
namespace MyModule
{
public class MyClass:IHttpModule
{
public void Init(HttpApplication context)
{
context.Error += new EventHandler(context_Error);
}
void context_Error(object sender, EventArgs e)
{
//// Get the Last Error in the system
Exception ex = HttpContext.Current.Server.GetLastError();
//Logic to log exception object ex in text file.
}
}
}
Registered in Web Site web.config as follows:
<httpModules>
<add name="MyModule" type="MyModule.MyClass, MyModule"/>
</httpModules>
Asp.net code, i have caused exception purpusefully in asp.net code as follows:
protected void Button1_Click(object sender, EventArgs e)
{
try
{
int a = 1;
int b = 0;
int c = a / b;
}
catch (Exception ex)
{
}
}
Actually i am logging exceptions in text file . But when excpetion occurs in asp.net web site nothing is being logged.
Cheers
Happy Programming
kiruba.sanka...
Member
543 Points
113 Posts
Re: Error Event not being called in HttpModule
Nov 03, 2011 12:01 PM|LINK
For example : Error should be throw from page, only then you can track here, instand of if you are handled in page using try..catch block. Those error will not be considered.
Code : In your Page :
Try this
try
{
/// your code...
}
catch(Expection ex)
{
throw;
}
-Good Luck
Kiruba.