DevTrends

DevTrends Blog

Web API

Wrapping ASP.NET Web API Responses for consistency and to provide additional information

Most well known public facing API's return a consistent response with a similar structure returned for all requests regadless of success or failure. This makes consumption of the API far easier and more intuitive. It also allows custom meta data to be added to every response. Out of the box, ASP.NET Web API does not use a common structure but it is very easy to change. This post explains how you can shape your responses by utilising a simple DelegatingHandler.

Read Article
Startup

Startup Tools Series - Part 2 - DNS Management

This is the second part of a new series of short posts about essential tools for startups. This time we look at DNS management - a critical yet often overlooked service.

Read Article
Startup

Startup Tools Series - Part 1 - Domain Registrar

This is the first part of a new series of short posts about essential tools for startups. As a startup, one of the first things that you will want to do is register a domain name and to do that, you will need a domain registrar.

Read Article
Azure

DevTrends has a new look and is now on Azure

We recently decided to move the website from traditional shared hosting to Microsoft Azure. As part of the move, we have updated the site to be faster, cleaner and work better on mobile devices. Hope you like it.

Read Article
Azure

Fixing Azure Blob Storage Content Disposition

The latest release of the Windows Azure Blob Storage API and Client Library supports the content-disposition header allowing you to force a file to download rather than display it in the browser. It also allows you to override the blob filename and specify a friendly download name. This can be very useful but you may find that it doesn't work out of the box. This article explains how to get it working.

Read Article
Azure

Hosting Web Fonts in Azure Blob Storage using the new CORS Support

We have been waiting a long time for CORS support on Windows Azure Blob Storage but the wait is now over. This post describes how to enable CORS allowing you to serve web fonts from Azure Blob Storage and the Azure CDN.

Read Article
Open Source

Using Unity.Mvc5 and Unity.WebApi together in a project

At Devtrends, we prefer to split our Web APIs and ASP.NET MVC sites into separate projects but I know that not all Unity.WebApi and Unity.Mvc5 users feel the same way. This blog post addresses use cases where people want to use both libraries together within the same project.

Read Article
Open Source

Unity.Mvc3 and Unity.WebAPI have new owners and new releases

We are pleased to announce that our popular open source projects Unity.Mvc3 and Unity.WebAPI are now once again being properly maintained. Our sister SaaS company FeedbackHound has taken over the day to day running of the projects and they have already released new versions.

Read Article
Open Source

Taking ownership of Unity.Mvc* and Unity.WebAPI

We are pleased to announce that we have taken ownership of the popular Unity.Mvc* and Unity.WebAPI projects. At FeedbackHound, we use both these libraries in multiple applications so we are very grateful be able to take control and maintain the projects going forward.

Read Article
Open Source

MvcDonutCaching has a new owner

Following on from the recent post asking for volunteers to take over some of our open source projects, I am pleased to announce that MvcDonutCaching now has a new owner.

Read Article
Open Source

Open Source Projects Looking For a New Home

For the last 2 years or so we have been maintaining six open source projects together with their associated NuGet packages. We have had a lot of support over that time and have had nearly 100,000 NuGet downloads to date which is fantastic. Unfortunately, other work commitments have meant that very little work has been done to maintain these projects in recent months. Rather than continue this way, I have decided to try and offload some of these packages in the hope that a new owner can devote some more time to them.

Read Article
Azure

Azure Web Sites Git Deploy For Multiple Project Solutions

If you are trying to Git deploy a solution with multiple web projects to multiple Windows Azure websites, you will find that it does not work out of the box. This post describes a simple way to workaround this omission by creating a custom deployment script. Don't worry though - it is dead simple.

Read Article
Open Source

Introducing the Unity.WebAPI NuGet Package

Whilst the IDependencyResolver interface in the new ASP.NET Web API is identical to its in ASP.NET MVC 3+ compatriot, it is nevertheless in a different namespace and assembly and thus, effectively a different interface. Unity.WebAPI brings the functionality of the popular Unity.Mvc3 package to WebAPI, allowing you to inject dependencies into your ApiControllers via Unity and have IDisposable components automatically disposed of at the end of the request.

Read Article
Open Source

Introducing Unity.WCF - providing easy IoC integration for your WCF services

There are numerous blog posts available that explain how to hook up Unity with WCF. Unfortunately, many of these are incomplete, too basic or just plain wrong. Additionally, as far as I can tell, nobody has created a NuGet package to get you up and running as quickly as possible. This post introduces Unity.WCF, an open source NuGet package that (hopefully) just works in most situations, deals with cleaning up IDisposable instances and also provides a nice mechanism for automatically adding WCF behaviors to your services.

Read Article
Unity

Using Unity's automatic factories to lazy load expensive dependencies

Automatic factory support in Microsoft's Unity IoC container is not something new, having been introduced with Unity 2.0 back in 2010. Unfortunately, not many people seem to know about it and the blog post that I used to find out about it is no longer available. This short post explains how to use automatic factories and why they can be useful.

Read Article
Open Source

What's New In MvcDonutCaching 1.1?

A new version of MvcDonutCaching has just been released with even more features plus several bug fixes. Following user feedback, this release centres on allowing MvcDonutCaching to be used in place of the built-in OutputCache attribute in many common scenarios. This should mean that you can take advantage of the many MvcDonutCaching benefits without losing core OutputCache functionality. V1.1 adds support for non-view action results and cache location specification and also fixes several known bugs.

Read Article
Open Source

Validating WCF service operations using System.ComponentModel.DataAnnotations

All WCF services operations need some level of parameter validation to ensure that the data passed to the operation is present and correct. Two popular methods are manual checking and the Validation Application Block (VAB) from Enterprise Library. This article discusses another option - using the validation features from System.ComponentModel.DataAnnotations.

Read Article
Review

Book Review - PhoneGap Beginner's Guide

PhoneGap is an interesting framework that allows you to leverage your existing skills in HTML, CSS and JavaScript to create native mobile applications in all of today's popular platforms. This is a review of PhoneGap Beginner's Guide written by Andrew Lunny.

Read Article
MVC

ASP.NET MVC Output Caching with Windows AppFabric Cache

Enterprise level web applications are typically hosted in web farms where in-process caching is less useful than a distributed caching approach such as Windows Server AppFabric or Memcached. Thanks to the extensibility features introduced with ASP.NET 4.0, modifying an application to use a distributed cache is a very simple process. This post explains how to create an AppFabric OutputCacheProvider and how to configure ASP.NET to use the new provider. We will also discuss a big limitation with the MVC3 OutputCacheAttribute and explain how this is addressed by the MvcDonutCaching NuGet package.

Read Article
Open Source

Donut Output Caching in ASP.NET MVC 3

Donut caching is the one form of output caching that is conspicuously absent from ASP.NET MVC 3 (and MVC4 as we speak) and is greatly missed by many developers. This post describes MvcDonutCaching, a new open-source NuGet package that adds donut caching to MVC3 in a simple and performant manner.

Read Article
IoC

How not to do dependency injection - using XML over fluent configuration

Virtually all the developers that I come across who do not like using IoC containers have been put off by verbose, error prone XML-based configuration. Many people do not even realise that a type-safe alternative is available in all the popular IoC containers. If you are struggling with XML config, fluent configuration could be the answer to your prayers.

Read Article
IoC

How not to do dependency injection - configuring the IoC container in unit test projects

You will often hear people say that using IoC allows your code to be unit testable, and they are of course correct. If you are doing dependency injection correctly, you code will inherently be unit testable. The subtlety that needs to be understood is how DI aids unit testing. It is certainly not the use of an IOC container which should have absolutely no bearing on your unit testing code.

Read Article
.NET

Programmatically Retrieving Items From Resource Files In .Net

If you are working on an international application, then you are almost certainly using resource files. In ASP.NET (including ASP.NET MVC) there are a number of different types of resource file including global (App_GlobalResources) and local (App_LocalResources) but most people will find the satellite assembly approach the best choice. When referencing resources from within your application, using strongly typed names is preferable in most cases but there are times where a more automated approach may be more succinct and less error prone. This article explains a simple way of querying a resource file for a subset of resources.

Read Article
IoC

How not to do dependency injection - the static or singleton container

Dependency injection and the use of IoC containers is becoming more and more popular but many development teams do not have the knowledge or experience necessary to fully utilise the power of the IoC container. In the next few posts, we will take a look at the most common mistakes and how to address them. In this post, we are going to talk about the static or singleton container and why this 'pattern' is such a bad idea.

Read Article
Open Source

Integrating The Unity.Mvc3 1.1 NuGet Package From Scratch

A new version of Unity.Mvc3 has been published that targets the recently released Unity 2.1. It is available as a NuGet Package (Unity.Mvc3) downloadable from within Visual Studio. You can also download the dll and the source code from codeplex. This article explains the changes in this release and goes on to explain how to do dependency injection in an MVC application using Unity.Mvc3.

Read Article
.NET

Stop using AutoMapper in your Data Access Code

A few months ago, Jimmy Bogard, author of the excellent AutoMapper wrote a great article about Autoprojecting LINQ queries. Now that Jimmy has done all the hard expression tree work, this article extends his example to include caching and simple flattening capabilities and goes on to show it in use in a simple EF 4.1 Code First application.

Read Article
MVC

Importing Namespaces into Razor Views in ASP.NET MVC 3

The way that namespaces are imported into views is quite different in ASP.NET MVC 3 depending on whether you choose to use the original ASPX view engine or the newer Razor engine. This article discuses these diferences and shows how you can make namespaces available to all views without an explicit import statement in each view.

Read Article
IoC

Configuration Settings Are A Dependency That Should Be Injected

Dependency Injection does not just apply to obvious dependencies such as repositories and logging components. It is very important to inject ALL dependencies including the less obvious ones. In my experience, one of the most overlooked areas is configuration. Many people seem perfectly happy to extract settings from config deep within their code. This is plain wrong. If you need to reference an AppSetting in your business logic, inject it. If you need a connection string in your data access code, inject that too.

Read Article
Open Source

Introducing The Unity.Mvc3 NuGet Package To Reconcile MVC3, Unity and IDisposable

Most IDependencyResolver implementations using Unity do not work with IDisposable and using them can lead to memory leaks and connection issues. Unity.Mvc3 is an assembly that includes a fuller implementation of IDependencyResolver that uses a child container per web request to ensure that IDisposable instances are disposed of at the end of each request. All of these complexities are taken care of by the assembly and integration into a project is as simple as adding a single line of code.

Read Article
MVC

Do not implement IControllerActivator in ASP.NET MVC 3

ASP.NET MVC 3 introduces two new interfaces to allow simple integration of IoC containers into the MVC pipeline, allowing many different types to be resolved using your IoC container of choice. These interfaces are IDependencyResolver and IControllerActivator but before you go ahead and implement both, let's take a look at whether they are both actually needed.

Read Article
MVC

The Complete Guide To Validation In ASP.NET MVC 3 - Part 2

This is second part our comprehensive guide to ASP.NET MVC 3 validation. In this article, we will write several custom validators by subclassing ValidationAttribute. We will include functionality to output HTML5 data-* attributes for use with client side validation. We will then add the client-side validation and learn about jQuery.validate and the Microsoft adapters that are used to convert the HTML5 data-* attributes into a format that jQuery.validate understands.

Read Article
MVC

The Complete Guide To Validation In ASP.NET MVC 3 - Part 1

The latest release of ASP.NET MVC (version 3) has a number of new validation features that significantly simplify both the validation code AND the html outputted to the client. This two-part article will attempt to cover all common validation scenarios and introduce all the new MVC3 validation features along the way. We will provide detailed explanations as well as full code examples that you can adapt for your own needs.

Read Article