aspnet / KestrelHttpServer

[Archived] A cross platform web server for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
2.63k stars 528 forks source link

Provide option to not catch all request exceptions #3106

Closed sambauwens closed 5 years ago

sambauwens commented 5 years ago

When I'm debugging my server code, I like to break on unhandled exceptions right into context. I noticed that when debugging my aspnet core application it never breaks in my code.

The last line of my stacktrace is :

at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

I did some research, and noticed HttpProtocol.ProcessRequestsAsync() does seem to catch all exceptions unconditionnally.

So I would appreciate a configuration option that I set when the debugger is attached and which tells kestrel not to catch exceptions.

benaadams commented 5 years ago

You can change the debugger settings to break when the exception happens https://docs.microsoft.com/en-us/visualstudio/debugger/managing-exceptions-with-the-debugger?view=vs-2017

Tratcher commented 5 years ago

What if we called Debugger.Break() for caught exceptions if the debugger was attached?

muratg commented 5 years ago

We won't be making any changes here. You can create a middleware to do a Debugger.Break with the try catch block.