Prevent Asp.net MVC WebAPI from stopping (needing to press continue) when exception is caught -


i have try , catch block in controller in asp.net mvc webapi project.

this exception if mess date input

an exception of type 'system.argumentexception' occurred in mscorlib.dll not handled in user code

additional information: item same key has been added.

i tried add following

      catch (exception e)         {             output.add("requeststatus", "fail");             output.add("errorsumary", "=== exception in soap request ===");             output.add("errorsuggestion", "effectivedate not in right format or date past");             logger.error("error: activatecontroller - effectivedate not in right format");         } 

but when exception triggered still have press continue button in visual studio make program keep running. is there way make exception doesnt stop running of program? (ie dont have click green continue button in visual studio)

i know should try , catch everytype of exception , handle them gracefully wanted built in failsafe allows keep running if 1 slips under rug (and log using nlog see if broken via splunk).

so turns out in order fix had change following setting in visual studio checked when running in debug mode.

the setting called

break when exception type user-unhandled .

i able confirm switching visual studio release configuration "debug release" program not catch exception, program no longer stop execution continuing catch time , time again without interrupting program. didn't realize debug configuration default had "break when exception type user-unhandled" turned on out of box.

you can see exception settings in 2 places have found. debug -> exceptions (and likewise set defaults if want re-enable behavior).

more information debugging settings can found here tools->options->debugging


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -