Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 08, 2013 06:55 PM by callmedev
0 Points
6 Posts
Jan 08, 2013 06:55 PM|LINK
Hi,
I found the following sample code for custom exception filter:
public class CustomExceptionFilter: ExceptionFilterAttribute { public override void OnException(HttpActionExecutedContext context) { if(context.Response == null) { context.Response = new HttpResponseMessage(); } context.Response.StatusCode = HttpStatusCode.NotImplemented; context.Response.Content = new StringContent("Custom Message"); base.OnException(context); } }
In the above code why base.OnException is there, what is the purpose of this and is it required?
Thanks
callmedev
0 Points
6 Posts
Why to call base.OnException
Jan 08, 2013 06:55 PM|LINK
Hi,
I found the following sample code for custom exception filter:
public class CustomExceptionFilter: ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
if(context.Response == null)
{
context.Response = new HttpResponseMessage();
}
context.Response.StatusCode = HttpStatusCode.NotImplemented;
context.Response.Content = new StringContent("Custom Message");
base.OnException(context);
}
}
In the above code why base.OnException is there, what is the purpose of this and is it required?
Thanks