TAG: ASP.NET

Navigation

Custom Ordering of Action Filters in ASP.NET MVC

I recently stumbled across something with ASP.NET MVC action filters where they weren’t being executed in quite the order I was expecting. More specifically, I had made a poor assumption that filters defined at the Controller level would all execute prior to any action-level filters. After all, that was the behavior I thought I had seen before, but it turned out that it worked a bit differently. In this post I will explore exactly…

Anonymous View Models in ASP.NET MVC Using Dynamics

The introduction of the dynamic keyword in C# 4.0 allows you to do a lot of things you couldn’t do otherwise, but it also makes it easy to forget that C# is still not a dynamic language, so there are limitations. Recently I found myself wanting to whip up a quick test page for something, with a very simple controller action and view. It wasn’t meant to be permanent, so creating a dedicated…

Attribute-Based Property Aliases Using MongoDB and NoRM

Since MongoDB is a document database, collections don’t have an enforced schema. Each document in a collection needs to store the names of all of its properties, making the length of that name more significant. Using abbreviated property names helps cut down on the storage space needed for each document, but it’s not ideal to mirror those abbreviated names in your object model. To help solve this problem, the NoRM driver provides an easy…

ASP.NET MVC: Do You Know Where Your TempData Is?

I recently discovered that despite the fact that I’d been using the TempData dictionary in my applications, I didn’t really have a full grasp on what it was doing behind the scenes. Of course this meant learning the lesson the hard way once something stopped working like I thought it would. I only really had myself to blame since in the end it was a simple case of RTFM, but it seemed like a…

Dynamic Views in ASP.NET MVC 2

One of the new features introduced in C# 4.0 is the dynamic keyword. So far I haven’t had much use for it, but lately I’ve discovered that it can be very useful when designing ASP.NET MVC views. It also has uses when interacting with COM APIs and other dynamic languages, but I’m going to focus on its use in MVC. If you’re using .NET 4.0 and ASP.NET MVC…