0

I have an exception thrown in my ASP.NET Core Web API project. And I do get the exception name and stacktrace and everything, but the problem is that I get that as a response to the API request, but I want Visual Studio to take me immediately to the exception where and when it was thrown, like I have placed a breakpoint to it.

This is something that used to work in regular ASP.NET Core MVC projects, but for some reason it doesn't work in Web API.

Also, to clarify - I don't have any global exception handling filter or middleware, I just call app.UseDeveloperExceptionPage(); to get the detailed exception in development, this is from my HTTP request pipeline:

if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
    app.UseSwagger();
    app.UseSwaggerUI();
}
else
{
    app.UseCustomExceptionHandler();
}
// Other irrelevant middlewares...
O. Shai
  • 703
  • 7
  • 22

2 Answers2

1

you need to set the Visual Studio like this:

enter image description here

link.

Xinran Shen
  • 8,416
  • 2
  • 3
  • 12
1

Based on @XinranShen answer I also needed to update the debug settings.

I checked the setting marked below:

enter image description here

O. Shai
  • 703
  • 7
  • 22