Skip to main content

Posts

ASP.NET Core SignalR– Configure logging

As we don’t have an official release yet of the ASP.NET Core SignalR package, it’s a quest to find the right information in the Github repo . Yesterday I lost some time searching on how to configure logging in SignalR. To enable logging you have to pass an extra parameter to your HubConnection specifying a loglevel: Supported log levels are:

Debugging websockets in Chrome

Debugging websockets using Chrome turns out to be quite simple. Here is a step by step guide: Hit F12 to open the Developer Tools in Chrome Go to the Network tab and select the "WS" filter to only show WebSocket connections.     Open a page where you are using websockets. You should see a request appear in the list.      Click on the name of the request, and select the tab "Frames" . Messages triggered by your client are shown in green, while messages from the server are white.

Optimize your memory usage when deserializing large JSON objects

During a code review of a customers code base I noticed they were doing a lot of JSON serialization and deserialization actions. As the JSON data was quite large, this caused high memory pressure.  Way to much time was spent in the garbage collector as too many (large) objects were allocated. To minimize memory usage and the number of objects allocated, Json.NET supports serializing and deserializing directly to a stream. Here is a code snippet:

jwt-decode - Decode a JWT token in your browser

During the preparation for a training I found the following great utility library; jwt-decode . jwt-decode is a small browser library that helps decoding JWTs token which are Base64Url encoded. Installation I installed the library using npm install jwt-decode Usage As I’m using webpack I was able to include the package using a require var jwtDecode = require('jwt-decode'); Next step is to take the token and call jwtDecode: var token = 'eyJ0eXAiO.../// jwt token'; var decoded = jwt_decode(token); console.log(decoded);

Angular error: Cannot find module '@angular-devkit/core'

Yesterday a colleague asked me for help with the following problem. Angular CLI was working fine on his system(he was using version 1.6.4 on his system), but when he tried to run an Angular project created using an earlier Angular CLI version, he got the following error: Cannot find module '@angular-devkit/core' We found 2 solutions that both seemed to work. Solution 1 Install the @angular-devkit/core package explicitly using  npm i -D @angular-devkit/core Solution 2 Upgrade the angular-cli version using npm update -g @angular/cli

Log Parser Studio

The last 2 weeks we had some production issues where an unexpected 401 message was returned from our IIS servers. To further investigate the issue, I got an old tool out of the dust; Log Parser Studio . Log Parser Studio is a utility that allows you to search through and create reports from your IIS, Event, EXADB and others types of logs. It builds on top of Log Parser 2.2 and has a full user interface for easy creation and management of related SQL queries. Log Parser Studio allows to query all kinds of log files using a SQL like syntax. It comes out of the box with a large list of sample queries that can help get started. How to use it Open Log Parser Studio(LPS.exe) Click on the New Query button or choose one of the queries from the library   A new query window appears Now it is time to first specify the LogType. Click on the Log Type link in the middle and choose the correct type from the list: Next we have to select the files to que...

ASP.NET Core - IHttpContextAccessor

ASP.NET Core introduces the IHttpContextAccessor interface as a way to provide access to the HttpContext. Before you can use it, you have to register it at application startup inside the IServicesCollection. During a code review I noticed that it was registered like this: This turns out to be wrong. The IHttpContextAccessor should be registered as a singleton. So the correct code is the following: More information: https://www.strathweb.com/2016/12/accessing-httpcontext-outside-of-framework-components-in-asp-net-core/