How to fix: UseExceptionHandler not working / executed on validation errors in ASP .NET core.


The following post explains exactly how to globally handle validation errors thrown by the ASP .NET core framework.

Centralized exception handling and request validation in ASP.NET Core


Validation errors will not trigger the “UseExceptionHandler”.

If you want to change the response for validation errors you will have to configure the “ApiBehaviorOptions”


    .AddJsonOptions(option => option.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local)



services.Configure<ApiBehaviorOptions>(options =>


    options.InvalidModelStateResponseFactory = ctx => new ValidationProblemDetailsResult(_logger);


p style=”background: #1e1e1e”>});



Read “” for more details.

How to show logging in karma jasmine unit tests.


In Karma v5.0.9 server the “console.log” statements, inside the spec tests as well as in your web application code, are logged to the terminal running the karma server by default.

If you want to turn this off, you can set the “client => captureConsole” to false.

You can also change the log level by setting the “logLevel” setting e.g. “logLevel: config.LOG_INFO” to log info messages and above.




Get raw content response from an xhr request copied from Google Chrome in PowerShell


Google Chrome allows you to copy an executed xhr request and replay it in PowerShell:

  • Open the developer tools (F12)

  • Open the network tab

  • Trigger the netwerk request by executing the functionality in you web application

  • Right click the request in the network tab, then “Copy” and then “Copy as PowerShell”


Now paste this in a PowerShell prompt and you should get the same result as in the browser.


If the request returns an exception (http error code), then you can use the following code to get more information on the error:

Just replace the text “<< paste request from google Chrome here >>” with the copied xhr request.


try {

  $webResponse = << paste request from google Chrome here >>


  Write-Host “Response: $($webResponse)”


catch {

  Write-Host “ErrorDetails: $($_.ErrorDetails)”

  Write-Host “ExceptionResponse: $($_.Exception.Response)”


p style=”background: #1e1e1e”>}