I have a question regarding how exactly this thing works.
public class GlobalExceptionHandler: ExceptionHandler
{
private string _pvtMsg;
public override void handle(ExceptionHandlerContext context)
{
//few if else conditions
if()
{
}
else if
{
_pvtMsg = "some value";
}
context.Result="Some random value depending upon if else execution";
}
}
Now when _pvtMsg is set after that, whenever exception occurs it always have that same value as before.
Does, when I set _pvtMsg = "a"; in the else if condition, the next time an error occurs _pvtMsg still have value "a"?
Is there only a single instance of handler available throughout the lifespan of my application and hence this is happening? Or are there any other reasons? Any documents for reference would be appreciated.
Btw: this handler is registered with the Register method of the WebApiConfig.
config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());