Leonard Inegbedion
Leonard Inegbedion

Reputation: 23

In ASP.Net C# would the Application end when and error occurs on the site or when Application_Error is triggered

Hello brilliant guys on Stackoverflow, please I would like to know if in ASP.Net C# would the Application end when an error occurs or when Application_Error is triggered? From my understanding, it shouldn't, I just want to be double sure

Upvotes: 2

Views: 657

Answers (4)

Ramesh
Ramesh

Reputation: 13266

Generally if an exception happens in a thread associated with a request, it triggers Application_Error event and if not handled will return a HTTP 500 error to the client.

But, an un-handled exception in a thread not associated with a request will take down the worker process (in other words, kills your application). This occurs even if you have a handler setup via the Application_Error method. MSDN Link for Exception in Managed Threads for more details

Upvotes: 1

Icarus
Icarus

Reputation: 63962

No, the application_end event will not be triggered when an unhandled exception occurs. Application_Error will be triggered instead.

Typically, Application_End fires when the App pool is recycled or when you restart IIS.

Upvotes: 0

pdriegen
pdriegen

Reputation: 2039

No, it won't. Application_End is fired with the hosting IIS process (w3wp.exe) terminates gracefully. The most likely cause of a graceful termination would be when IIS recycles the process as it does at a regular interval.

Upvotes: 0

Shai
Shai

Reputation: 25595

Most likely, will throw you to a HTTP 500 error page if you're not handling exceptions.

The application itself doesn't "end" as it's a web application. Any re-entry to the website will likely to start a fresh session.

Upvotes: 0

Related Questions