while catch and handle a duplicate entry-exception to continue with the app-workflow, i would like to prevent the windows event log to insert the exception.
to be clear: i dont want to turn off exception logging globaly in my asp.net core application. i only want to prevent logging on a specific codespace and specific exceptiontype.
ideas?
bool success = false;
try
{
await dbcontext.AddAsync(order);
await dbcontext.SaveChangesAsync();
success = true;
}
catch (DbUpdateException ex)
{
if (ex.InnerException != null)
{
if (ex.InnerException.Message.Contains("Duplicate"))
{
success = false;
}
}
}
return success;