Custom routing to support multi-tenancy applications

The company I currently work for has many brands so they are looking for a website that can be restyled for each brand. They also want the styling information to be managed through an admin area rather than have to go to the development team each time they want to change something. To that end […]

Changing the default Assembly/Namespace on an MVC appliction

TL;DR When getting an error message like this: Compiler Error Message: CS0246: The type or namespace name ‘UI’ could not be found (are you missing a using directive or an assembly reference?) when compiling Razor views after changing the namespace names in your project, check the web.config file in each of the view folders for […]

The difference between & and && operators

Here is a bit of code that was failing: if (product!=null & !string.IsNullOrEmpty(product.ProductNotes)) If you look closely you can see it uses just the single ampersand operator, not the usual double ampersand operator. There is a significant function difference between the two that under normal circumstances may not be obvious when performing logic operations on business […]

Setting up Code Coverage in Team City

The project that I’m working on has a rather spotted history for unit tests until now. There would be periods of people actually writing them, but then come unstuck when a random test failed and eventually the tests would be allowed to rot a bit, until something spurned everyone back to life again. However, unit […]

Code Review: Making a drop down list out of an enum

I’ve come across code like this a couple of times and it is rather odd: IEnumerable<CalendarViewEnum> _calendarViewEnums = Enum.GetValues(typeof(CalendarViewEnum)).Cast<CalendarViewEnum>(); List selectList = new List<SelectListItem>(); foreach (CalendarViewEnum calendarViewEnum in _calendarViewEnums) { switch (calendarViewEnum) { case CalendarViewEnum.FittingRoom: selectList.Add(new SelectListItem { Text = AdminPreferencesRes.Label_CalendarViewFittingRoom, Value = ((int)calendarViewEnum).ToString(CultureInfo.InvariantCulture), Selected = (calendarViewEnum == CalendarViewEnum.FittingRoom) }); break; case CalendarViewEnum.Staff: selectList.Add(new SelectListItem […]

Previewing Config Transforms

Curiously, I didn’t know about this until recently and it is such a useful thing too. You can preview the results of your configuration transformation from within Visual Studio. First of all, right click the transform file and select “Preview Transform” Then it will show you the differences between the original web.config file and the […]

Deploying a Node.js with Express application on Azure

By the end of the last post, there was enough of an application to deploy it, so let’s deploy it. Prerequisites An FTP client to get at the files on Azure. A GitHub account (or other source control, but this walk through uses GitHub) to deploy to Azure. And an Azure account – this walk […]

Node.js with Express – Come to the dark side. We have cookies!

So far, so good. At the point the application displays a list of languages and will display the language that the user picked. However, for the flashcards to work, that selection will have to be remembered. As there is so little state, it is possible to store that in a cookie. Express handles the creation […]

Node.js with Express – Getting form data

Now that view engines are wired up and working on this application, the next area to look at is getting data back from the browser. By default Express doesn’t do anything with form data in the request and a piece of “middleware” needs to be added to get this to work. The reason for this […]

Express for node.js – View Engines

In the last post, Express Hello World, I talked about getting started with an Express application in Node.js. In it, the output was rendered by writing HTML directly. In most situations that is undesirable and some sort of view or template engine is better suited to rendering the output. This post follows on directly from […]