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 view model class in the project seemed like overkill. I figured I could just return an anonymous object as the model, and use a dynamic view to display it. I was wrong.

READ MORE

Tags: , ,

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…

READ MORE

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…

READ MORE

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…

READ MORE

Templated Helpers and Custom Model Binders in ASP.NET MVC 2

One of the really cool new features in ASP .NET MVC 2 is templated helpers. The basic idea is that you can define a template for either displaying or editing a particular data type, and it will be used…

READ MORE