Contents tagged with

  • Custom XML model binder for ASP.NET MVC

    In an earlier post I wrote about using an XML value provider to allow you to send XML to your .NET MVC action methods. This is great, untill you want to accept XML where you have a model that needs XML atributes to control how it's deserialized. As the value provider stage happens before mondel binding it has no knowledge of the model objects that the values will be pushed into. So it can't look at your model class's XML attributes.

    In cases like this, you're better of using a custom XML model binder.

    To setup an XML model binder you need to create a model binder and a model binder provider. … more

  • A .NET MVC Helper to create HTML wrapping elements

    In HTML when you want to create a box around some content with rounded corners or some other nice feature it would be nice if you could just wrap that content in a <div> or a <section> tag and CSS would do the rest. However this rarely seems to be the case, particularly if you want the HTML to render well in older browsers. The views in my latest .NET MVC 3 project were full of repeated opening and closing sections of HTML for something that we called a chunk, which is just our word for a box with rounded corners that groups together related elements on the page. Sometimes a chunk … more

  • .NET MVC Security

    Most web security attacks are based on doing unexpected things to user input to fool the website into doing something it shouldn't. As web developers we all know this, but it's hard to keep track of all the exploits that are out there and it's easy to overlook things. The attacks that target the users of a website, work by making them enter unexpected input without them realising it. This often relies on them being logged on to the target site in question so their browser is authenticated when the user clicks on a link in a phishing email.

    These notes are about how to avoid making a site … more

  • Amazon Simple Email Service and MailChimp

    Amazon announced in January their new Simple Email Service. This was timely as the project I'm working on at the moment needs to send out quite a lot of transactional emails. A few days later MailChimp announced they'd created a layer on top of the Amazon service that gave some extra and very useful reporting features.

    We were sending emails from our webserver's mail server. This was fine most of the time, but even in testing we were finding that a few emails were getting turned down as spam by people’s email clients. Using an email sending service was something we were considering to … more

  • Sending XML to an ASP.NET MVC Action Method Argument

    I read a great article recently by Phil Haack on sending JSON to an action method. This was very timely as I wanted to do exactly that in the REST API I've been created for a video hosting website. However, I wanted to make it work with XML as well as JSON.

    Phil Haack creates something called a JSON value provider, so I followed his example and created an XML value provider. I've used it on two projects now and it's worked a treat. I thought I'd share it with the world in the hope that it will be useful to others.

    Source code

    XML Value Provider (C# source)

    To get this working in your … more

  • Microsoft Webcamps

    Last weekend I went to Microsoft Webcamps London: a two day event mainly about ASP.NET MVC and a little bit about the Entity Framework. It was a two day event mainly aimed at Microsoft developers who'd not used .NET MVC before. I've done a few MVC projects now, but there's always more to learn and it's always good to meet other people doing similar stuff to you. The first day was a series of talks by Jon Galloway and Christian Wenz. The talks were excellent and even though they covered a lot of things I already knew, I still found out lots I didn't and made lots of notes. The second day was … more

  • A quick project. Is there a strike?

    This was just a little Sunday project inspired by the number of strikes we’ve been having and the website. lists organisations that have been experiences strikes and then has a simple yes/no page for each one.

    As the site is very simple it was also a nice test bed for a few things I’ve been learning about lately. It runs on ASP.NET MVC (it may be the simplest MVC site ever), has an Entity Framework data model keeping track of the strikes and has a Dynamic Data admin section.

    There is a small unit test for the project using xUnit and I& … more

  • 1