I realize this is a shot in the dark and not the best practice or way of going about it, but I want to do specific logging information as the exception is thrown. It is important that the state of the web form does not change.
You can use
try
{
}
catch(Exception ex)
{
//your treatment does not contain throw ex.
//mute exception in order to not change state
}
You can use this in your webform or in your gloabl.asax in Application_Error (in order to centralize exception treatment)
try
{
ExceptionProneCode()
}
catch(Exception ex)
{
WriteToSomeLogFile(ex.Message);
//if you want the exception to bubble up from this point,
//than you would type "throw;"
}
如果我们在ASP.NET上下文中进行交谈,则Application_Error事件将是放置全局异常日志记录块的好地方。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.