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. [code language=”csharp”] 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); [/code]

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 »

HTML5: Drop-in prerender and prefetch script

Reading about prefetch and prerender, and especially Chromes prerender, got me thinking that this could to some extent be automated. My blog has become increasingly slow and I though that this would work as a simple quick-fix. This script relies on jQuery. Prefetch At startup (document ready) it will find any a-links tagged as “prefetch”… Read More »

Legacy app: Net-Chat 2.0a (Quick Basic 4.5, DOS)

Recently got some old tapes recovered. There I found an old chat program I wrote in QB45 in 1996 (I was 16 years old). I installed Windows XP under Hyper-V to test it out since Windows 8 doesn’t run 16-bit DOS programs. But I wanted to have the executable work on my computer so I… Read More »

Multiple deployment configs in one config file with ACL

Most projects that is deployed into production require some kind of config change upon deployment. Often it is the connection string that varies, but it can be any number of custom settings. Forgetting to change the config file when deploying, or forgetting to change config back on your dev machine after deploying can have disastrous… Read More »

Alternative directory layout for MVC

In .Net the MVC pattern is implemented through a template project. The project is set up for you when you create a new MVC application and imposes certain patterns on you. And that is exactly what MVC is, a pattern. By default you will create a controller, a view and a model. Usually you add… Read More »