Posts Tagged as C#

The preview release of Sitecore 6.6 comes with first class support for ASP.NET MVC. If you want to get serious about MVC programming the first thing you’re going to want to do is to add support for your favourite dependency injection container. In th...

Filed under: C# Dependency Injection Sitecore

To complement my post on recursive joins to create hierarchical structures, here's the opposite code to flatten a hierarchy by performing a recursive select in LINQ and returning a flat IEnumerable<T>. Consider the following hierarchical data:NodeDat...

Filed under: Algorithms C# LINQ

Here's a clean solution to doing recursive hierarchical joins in LINQ and C#. I couldn't find an example that didn't use an intermediate "node" class, so I'd like to introduce my approach which provides extension methods to IEnumerabe<T> for doing re...

Filed under: Algorithms C# LINQ

I recently implemented a pager in ASP.NET MVC and thought it would be worth sharing. It uses fluent syntax - a technique I've not seen used much in MVC to solve similar problems so I thought I'd throw it out there! At first glance, MVC has a much mor...

Filed under: ASP.NET C# MVC

The Google +1 button lets visitors to your site recommend and share your content. I've created an ASP.NET server control to encapsulate the JavaScript you need to embed on your page. Using my server control you don't need to keep visiting the Google...

Filed under: ASP.NET C# Google Plus

Whenever I find myself needing to use a symmetric encryption algorithm, I always seem to write more or less the same code substituting whichever built in .NET cryptography class I need to use. So I decided to write a generic encrypt/decrypt cipher ut...

Filed under: C# Cryptography Security

The Event Broker is an implementation of the Observer pattern. The key benefit of an Event Broker is that it offers a loosely coupled mechanism to broadcast and receive events. This is especially useful in ASP.NET where you want to raise events in on...

Filed under: ASP.NET C# Patterns

The AVL tree is a rigorously balance binary search tree with very fast and stable insert, delete and search times. I like the various .NET dictionaries but have been unimpressed by their performance. So, after researching efficient dictionary algorit...

Filed under: Algorithms C# Performance

In this post, I thought I'd look at a complete server-side and client-side solution for validating credit card numbers using the LUHN algorithm for both ASP.NET Web Forms and MVC. The core code uses some nice LINQ that I have previously blogged about...

Filed under: Algorithms ASP.NET C# JavaScript LINQ MVC Security

In certain circumstances it can be useful to execute code in a class in its own application domain. We will take a look at how to use an application domain to isolate and execute code using a generic class wrapper. An application domain provides a la...

Filed under: C#

The RC4 algorithm is a symmetric stream cipher and despite having known security vulnerabilities, RC4 is still widely used. I'm quite fond of RC4 due to the ease of implementation which made RC4 an ideal choice of symmetric encryption algorithm back...

Filed under: Algorithms C# Cryptography Security

It's a common requirement to strip tags from HTML documents whether you are trying to extract plain text from HTML, or remove tags users have entered in text input fields or textarea fields on forms. The following HTML utility class demonstrates how...

Filed under: C# HTML LINQ

Cross Site Scripting, or XSS for short, is a form of HTML injection exploit where an attacker will attempt to embed malicious JavaScript, Java (Applets) or ActiveX code in HTML tags like <script>, <form>, <applet>, <iframe> and <object>. These HTML t...

Filed under: ASP.NET C# Security

If you have ever worked on a project involving maps (such as Google Maps), the chances are you will need to get the longitude and latitude for an address or set of addresses that have been entered by a user or have been supplied by a customer in a fi...

Filed under: C# Google Maps

There is one main limitation with FindControl in ASP.NET: it only looks in the NaminingContainer of the control you are searching within. Here is a better, much improved version of FindControl for ASP.NET written in C# as an extension to the Control...

Filed under: ASP.NET C# LINQ

The MD4 hash algorithm is a member of RSA's family of hashing recipes. However, due to certain security design flaws it is no longer used in modern cryptography. Surprisingly, it still plays a vital part in Microsoft Windows NTLM authentication and i...

Filed under: Algorithms C# Cryptography LINQ Security

Valid XHTML 1.0 Strict