How to Implement Cross Domain Requests (CORS) in WebAPI, old school

WebAPI is awesome. It allows .NET developers to quickly set up a public API for any data with minimal effort. WebAPI has been available for a while and with each iteration, it grows stronger and more versatile. However, there is no point in offering an API that no one can consume it. WebAPI works great straight out of the box for GET requests. However, once you start using it for POST, PUT or DELETE operations, then CORS kicks in and drops requests from hitting the server. CORS stops any cross domain requests so if your api is running at www. …[read more]


An introduction to JavaScript Unit Testing with qUnit and Sinon.js

If you are developing for the web – apps or websites, then it is almost impossible to escape JavaScript. At some point, you will write some client-side code and as the application grows and the requirements become more complex, your JavaScript code is bound to grow with it. Like with every other complex piece of code, we need to be confident that the code behaves as expected. It doesn’t matter if you decide to use TDD or not, what’s important is to test your code. You can do this manually, very tedious and error prone, or programmatically. The choice …[read more]


Getting Started with RabbitMQ on Windows

RabbitMQ is a great queuing tool that can run on a variety of platforms. If you are planning on doing any distributed, asynchronous processing and you need a system to queue and process items in the background, then you should seriously consider RabbitMQ. The online documentation is great and there are plenty of tutorials that can take you through the basics of creating and consuming queues in your application. However, before you start typing any code, you first you need to get RabbitMQ up and running somewhere (local system, server etc). In this post, we will go through the installation …[read more]


An introduction to the Common Logging API for .NET

Most developers know that logging is an invaluable tool especially when trying to troubleshoot issues with code running on production. In .Net, there is a plethora of tools to choose from such as Log4Net, nLog, Elmah etc. Each tool has its pros and cons so the decision on which one to use is usually based around the project requirements, complexity, performance and so on. What the [Common Logging API](http://netcommon.sourceforge.net/index.html target="_blank) brings to the game is a lightweight “infrastructure” logging platform that allows developers to focus on the logging requirements instead of the …[read more]


Disabling NuGet Package Restore

Yes, this is counterproductive and a step backwards, but if you are working in an environment where your build/CI server doesn't allow NuGet Package restore then you will need to disable it. This may sound straightforward and something that should be easily supported by NuGet, but I'm afraid you are out of luck. To disable NuGet package restores, you will need to perform some manual changes to your .csproj files To fully remove package restore just follow the steps below: 1. Close down the solution Before performing any project file changes, you will need to close down the solution …[read more]


A C# Encryption provider for Azure Websites

Azure.Security, my second OSS project has been released! 1. What is Azure.Security? Azure.Security is an Azure specific piece of software designed to provide cryptographic services to an application deployed to Azure Websites platform. One of the issues that you may come across when using this platform is data encryption and key management. Luckily, Azure Websites are happy to run code from the System.Security namespace, but there is no easy way to securily manage private key(s). And that's where this project comes to fill in the gap. Azure.Security uses a number of Azure features in …[read more]


Generic Repository with Entity Framework

My first NuGet package and OSS project is live :) What an exciting day! Lots of new releases announced in the last couple of days so why not add to the funfair and release my own OSS? This is a piece of code that I had to develop for a client and it took some effort. During the development of this library I tried to make as generic and modular as possible, which made it quite easy when I decided to share it with the community. The project is now live and there is a public repo on GitHub in hope …[read more]


Updating an MVC Partial View with Ajax

Partial views in ASP.NET MVC are great. They allow you to update only a part of the DOM without having to perform a full page refresh or a postback. Surely, there are many ways to achieve this, such as ajax and WebAPI, however, partial views have one major benefit over the other methods: Strongly-typed datamodels! Using this approach, the controller can push a nice object model back to the partial view instead of Json and we can take advantage of Razor and/or scaffolding for data presentation while enhancing the whole user experience. In this example, we will create …[read more]