Ajden Towfeek

Towfeek Solutions AB

Migrating ASP.NET MVC to WebApi with no breaking changes






Metod override header



Exception handling filter




Request body model binding and query params



Posting Files



Beaking change in serialization/deserialization JavaScriptSerializer -> Newtonsoft.Json



MediaFormatters Content-Type header





WinRT app @ Labdays

Installed win8 on my work laptop not too long ago so I decided to create my first winrt app during lab days at work. Due to lack of imagination I created a simple dashboard app for our product SAFE (really ugly page on saabgroup btw).

Started of by looking at some sessions on channel9 and googled design patterns, frameworks and ended up with the following:

I ended up writing a custom navigation service that I bootstrapped on application startup to make the IOC container from MVVM Light play nicely together with the AlternativeFrame from WinRT Xaml Toolkit. If you pay attention to the navigation between pages you can notice the nice dissolve transition which is done in AppShell.xaml in only 4 lines of markup.
Once I got the basic architecture in place I noticed that the panorama control from windows phone was missing for winrt. One google search later I found a blog post that addressed this issue so I ended up copying some code since I didn't want to install the entire nuget package win8nl. What it basically does is to add a panorama behvior to the FlipView control. The sad thing though is that you can't flick the screen if you don't have a touch screen, which is extremely frustrating!
As for what goes for component arts data viz library I really think it's not worth to pay for (trial is free), in the short time I played around with it I stumbled upon several bugs. An ugly work around for the PieChart control can be seen in the code behind file MainPage.xaml.cs. When data binding to an observable collection the control goes bananas as items are added to the collection, I needed to reset the DataSource for each added item for it to work properly.
All and all I'm pretty satisfied with the choice to use MVVM Light together with WinRT Xaml toolkit and the custom navigation service, I will definitely reuse that part for other projects.
Anyways the result can be seen in the vid below, you can get the source code here, if you're interested in how I hooked up the components and architecture. You will probably not be able to run the application since it requires our back-end and I didn't spend too much time on exception handling.


Merry x-mas everybody and a happy new year, I'm off for two whole weeks!


Performance measurement ASP.NET MVC vs. WebAPI



MVC (IIS) 0.42 41.83 2391
WebAPI (IIS) 0.35 35.06 2852
WebAPI (Self Hosted) 0.12 11.67 8567






Dell 5530 HSPA Driver for Windows 7 on E6410

So after a couple of hours of struggling I finally managed to get it working!

What I basically needed to do was to remove the machine check for the Dell 5530 Windows 7 driver installer for E6400 http://downloads.dell.com/comm/R251153.exe.

I've uploaded the modified msi here, hope it saves somebody a headache.


Noticed that my modified msi will make the OS crasch when recovering from sleep or hibernation. A better solution is to uninstall the old driver, download the enterprise client cab and update the drivers for the unknown devices from the device manager. Just browse the top level of the unpacked cab (E6410-win7-A09-9TW7N\E6410\x64) and check the "Include subfolders" checkbox. After a reboot new unknown devices appeared, just did the same thing and violá it worked, works on my win8 machine as well!


Building real-time web app with SignalR



PM> Install-Package EntityFramework
PM> Install-Package knockoutjs
PM> Install-Package SignalR


The only entity I want to store is a chat message:

public class Message
    public int MessageId { get; set; }

    [Required, MaxLength(200)]
    public string Text { get; set; }

and the actual database context as 

public class DatabaseContext : DbContext
    public DbSet<Message> Messages { get; set; }


Database.SetInitializer(new DropCreateDatabaseIfModelChanges<DatabaseContext>());


public class Messages : Hub
    public void GetAll() { ... }


$(function () {
    // proxy created
    this.hub = $.connection.messages;

    // method invoked by the server when a message is added
    this.hub.messageAdded = function (m) { ... };

    // how we send a message to the server


Screenshot of desktop browser and windows phone emulator browser:

Download the code (793,9KB) for full example.