Showing a list or table of data in groups is very common, and fortunately also very easy to do with LINQ. In the end we want our data to look something like this: Continue reading
Mapping relational table data to a tree structure in MVC
With the advent of MVC in ASP.NET, proper object oriented code is encouraged more than ever, and Razor makes it a joy to work recursively with tree structures. So how do we go about converting our SQL table data to a tree structure? Continue reading
Localization with fallback using LINQ
So you need to support multiple languages in your website, and you need the system to fallback to a default language if no translation is available. Fortunately LINQ is here to help and can do it all within a single SQL statement.
Since localization is a basic need for all international applications, I have made a simple structure, which can be applied in situations where an entity is required to have localizable values.
Continue reading
Firefox auto login with Windows Authentication and AD
When creating intranet websites, Windows Authentication will take care of all your user identification needs. Both Internet Explorer and Chrome will automatically pass your NTLM (Active Directory) user credentials to the server, but Firefox will not and instead presents the user with an ugly login prompt. Fortunately it’s quite easy to enable this in Firefox with a simple configuration change. Continue reading
View source on the iPad and iPhone
As a web developer I’m frequently looking at the source code of various websites. Lately my new iPad has become my primary tool for surfing and reading documentation, but alas it completely lacks a view source feature.
A fine solution is to create a bookmarklet, which is a piece of JavaScript saved as a bookmark. When you want to see the source of a web page, just click the bookmark and the source of the page is displayed. I was inspired by this bookmarklet by Rob Flaherty, but it has a few shortcomings. To improve upon the bookmarklet concept, I created my own version with a few more bells and whistles: Continue reading
Gmail+ your email – filter maillists and catch spam
A great “hidden” feature in Gmail, is the option to append a + followed by any text you like to the username part of your email address.
This text will be ignored by Gmail, and you will receive your emails as usual, but it allows you to create unique email addresses on the fly. Continue reading
Custom MembershipProvider, Principal and Identity
Recently I ported a large website from ASP.NET Web Forms to the shining new ASP.NET MVC 3. During this process I also decided to implement “proper” MembershipProvider-based security instead of a simpler, custom HTTP module we were running.
As I started implementing my custom MembershipProvider, I became a bit confused, however, about the sheer number of classes you have to implement/override. I ended up spending quite a lot of time searching for help, so here I will attempt to give a “shortcut” overview of the structure of the MembershipProvider model and lessons learned. Continue reading
Using URI hash instead of query strings
A URI hash is a great way to make JavaScript/AJAX pages with dynamic content bookmarkable. It can be used in a manner similar to query strings, but changes will not cause a new page request. This allows you to store data in the URI which can be read and changed by JavaScript without ever reloading the page. Continue reading