Home > Software design >  ASP.NET Core Web API - Exception is not showing immediately in Visual Studio
ASP.NET Core Web API - Exception is not showing immediately in Visual Studio

Time:02-17

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...

CodePudding user response:

you need to set the Visual Studio like this:

enter image description here

enter image description here

  • Related