IIS redirect HTTP to HTTPS but allow Let’s Encrypt

Let’s Encrypt makes it easy for everyone to use HTTPS. The Windows client letsencrypt-win-simple simplifies installing and updating certificate in IIS. Using IIS URL Rewrite function you can allow Let’s Encrypt certificate retrieval/renewal and redirect all visitors to HTTPS URL of site.


Template replacement engine

Using Regex as a template engine is an efficient way to replace strings in a template. Regex replace method supports executing a method upon match. We can populate a dictionary and make a lookup on all matches. This way we do the replacement in a single pass, rather than executing multiple .Replace(). Since dictionaries can be made case insensitive we have… Read More »

Norske fødselsnummer i C# / Norwegian national ID numbers in C#

Code to verify Norwegian national id number (fødselsnummer / personnummer) written in C#. Obeys 2013 standards as described in this Wikipedia article. Please let me know how if you find bugs / improvements. :)

(PS: This code is easy to test in LINQPad. Select C# Program, paste it in and hit run.)

Investigating Unity hang on second run (multi-threading)

Background he problem of Unity hangs on second run may have multiple causes and can sometimes be difficult to debug. When searching for an answer I see many with the same problem. I am therefore sharing a my debugging process in hope that it can help others solve their own problem. The problem Unity has had a problem… Read More »

C# Regex for verifying e-mails

Regex for matching e-mail in C#. Came across http://emailregex.com/ which has a horrible example, so ended up making my own loosely based on that. It leaves much to be desired, but will cover most use cases well enough.


ASP.Net 5 Identity Framework 3.0 manually adding users

Identity Framework 3 is in release candidate along with ASP.Net 5. The problem I set up a web project in ASP.Net 5 and created a controller for user import. It’s just some simple code that attempts to add multiple users. Adding a single user works great, but if I attempt to perform multiple operations in one go I… Read More »

ASP.Net 5 Areas

Visual Studio 2015 with ASP.Net 5 doesn’t support Areas in the GUI editor. Hopefully that will come, but until then here is a simple workaround. Create folder structure In the root of your project (not wwwroot) create the folder structure for Areas manually. In this example I created an area named “Foobar”. Edit Startup.cs to add routes for… Read More »

Better text console for C#

I recently discovered how slow Console.MoveBufferArea actually is. I used it for writing NLog output to a console and discovered that at times of high output it became dead slow. I could at times see it flicker and update line for line while the whole machine temporarily came to a crawl. As I searched the web I found… Read More »

Optimizing RDP for casual use

Optimizing RDP client/server for casual use. Make it use less bandwidth. Get higher throughput and adaptive transfers. Revisit Back in 2011 I wrote a blog post on optimizing RDP in Windows 7. I’ve been thinking of updating that post for some time, and now finally got around to it. Background Since sometime around 2000 I have been working… Read More »