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. <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <rule name=”Allow LetsEncrypt” patternSyntax=”Wildcard” stopProcessing=”true”> <match url=”.well-known/*” />… Read More »

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… Read More »

Norwegian personal number verification in C#

Code to verify Norwegian personal number (personnummer / fødselsnummer) written in C#. Obeys 2013 standards as described in this Wikipedia article. Please let me know how if you find bugs / improvements. :) public static class NorwegianPersonalNumberValidator { // Implementation of Norwegian personal number verification based on specifications outlined on https://no.wikipedia.org/wiki/F%C3%B8dselsnummer // Version 1: 2016-12-07 Tedd… 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. public static readonly Regex _emailRegex = new Regex( @”^[\w0-9!#$%&’*+/=?^_`{|}~-]{1,50}(?:\.[\w0-9!#$%&’*+/=?^_`{|}~-]{1,50}){0,8}” + @”@(?:[-\w0-9]{1,50}?\.){1,10}[-\w0-9]{2,50}?$”, RegexOptions.Compiled);    

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… 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… 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… 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… Read More »