How to validate a text input for only printable ASCII characters in ASP.NET MVC

01 Mar 2016

Let’s dive right in, plain and simple: for some reason, you need to make sure that your users don’t enter any non-printable characters into a text input field on a form. Maybe the data needs to travel to far reaches of the known universe, to a remote ancient banking backend system that runs on COBOL and mainframes (fueled by the energy of a dying brown dwarf). Or maybe the column in the database where this data is going to end up has never heard of Unicode. Or maybe that’s just one of those unexplainable, irrational so-called “business rules”, that some aspiring manager somewhere up in the ranks decided to implement.

Read more →

How to get organic search traffic back after broken Jekyll 3 upgrade

13 Feb 2016

It’s a fine day, your site runs smoothly, thanks to Jekyll with its static HTML generation and your clean and clever markdown. Then for some reason you decide to have a look at the Google Analytics Organic Search report and suddenly you see that your traffic just jumped off the cliff.

Read more →

Subscribe now and get helpful tips on developing .NET apps - never miss a new article.

You can unsubscribe at any time. I'll never share your email with anyone else.

How to trace SQL Server database errors and exceptions with SQL Profiler

07 Oct 2015

Sometimes, when errors or exceptions happen you can’t just attach a debugger to your web app - for example, errors may happen only in production, and you can only sit and watch the error logs fly past, or sometimes there are even no meaningful logs available. Maybe you need to debug a closed system - proprietary component/NuGet package that fails. Maybe it’s a combination of several factors

Read more →

How to avoid and fix NullReferenceExceptions in ASP.NET MVC

30 Jul 2015

Quite often people stumble into same problems again and again, and getting a NullReferenceException is the one that occurs most frequently, and frankly, can be quite annoying. This problem happens when writing brand-new ASP.NET MVC code, such as controllers or views, but also when modifying existing code that used to work just fine, but somehow suddenly got broken. Here I want to show you why these exceptions happen and how to fix them, so you can stop wasting your time and do more of the programming that you actually enjoy.

Read more →

How to use Bootstrap 3 validation states with ASP.NET MVC Forms

15 Feb 2015

Recently, when writing code for my blog post on drop downs, “DropDownListFor with Dictionaries in ASP.NET MVC and why SelectList wants to kill you”, I stumbled over an interesting problem – when using ASP.NET MVC HTML helpers, such as @Html.TextBoxFor() and @Html.DropDownListFor() to render controls and @Html.ValidationMessageFor() to render validation error messages, I realised that ASP.NET MVC uses its own CSS classes, so no errors are getting highlighted when using Bootstrap 3.

Read more →

DropDownListFor with Dictionaries in ASP.NET MVC and why SelectList wants to kill you

06 Jan 2015

I would like to show you how to use ASP.NET MVC helper function DropDownListFor and SelectList class with generic Dictionaries, such as Dictionary<string, string> or Dictionary<int, string>. Dictionaries can be quite useful for a number of scenarios – serving as a data source for select lists of countries, states, time zones, age ranges, genders – basically any pre-defined, fixed-set options lists.

Read more →

Using Drop Down Lists with enums in ASP.NET MVC

17 Nov 2014

ASP.NET MVC is a very powerful, yet quite complex (if not complicated) web development framework. There’s a heaps of various namespaces, classes and functions. It’s bloody hard to figure out which particular class or function overload you need to use for your specific task.

Read more →

Learning How To Learn Better

29 Oct 2014

There probably was only a handful of subjects at school and later at uni that I liked - and I despised or ignored the rest, doing everything I could just to get a good enough grade to get to the next term. It wasn’t all that different at work after that - whenever something boring had to be done, I’d distract myself with whatever I could - news reading, social media, pretending to ‘learn’ by reading tech articles/books. Sometimes that worked out ok, other times it totally sucked due to the stress of looming deadlines.

Read more →

Using simple Drop Down Lists in ASP.NET MVC

15 Oct 2014

It’s surprising how many subtle, but frustrating traps one can fall into when building sites with ASP.NET MVC. Creating forms for the web is one of them. It’s common to spend hours on something trivial, such as displaying a selected value in a DropDownList on postback, or getting that selected value in a controller. Quite often it happens when you just start learning ASP.NET MVC or upgrade from an older tech. And boy, is this frustrating as hell – instead of building an actual web app, you spend hours wrestling with the framework.

Read more →

Adding a coins pocket to Mighty Wallet: a DIY adventure

22 May 2014

When my old leather wallet started falling apart I decided I could do without another piece of an animal’s skin. Turns out in this day and age you don’t need to kill a cow to make a wallet - just use something synthetic, like tyvek.

Read more →