<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv" -->

---
title: Using the ASP.NET MVC ModelBinder attribute - Second part
description: A follow-up tutorial demonstrates how to fully implement a custom ModelBinder in ASP.NET MVC Preview 5 so that action methods can accept complex objects (like...
canonical: https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Using the ASP.NET MVC ModelBinder attribute - Second part | daily.dev
og:description: A follow-up tutorial demonstrates how to fully implement a custom ModelBinder in ASP.NET MVC Preview 5 so that action methods can accept complex objects (like...
og:url: https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv
og:image: https://api.daily.dev/og/posts/gTg1GRGCV.png
og:image:alt: Using the ASP.NET MVC ModelBinder attribute - Second part
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Using the ASP.NET MVC ModelBinder attribute - Second part

**[Maarten Balliauw](https://daily.dev/sources/maartenballiauw)** · 4 min read · 0 upvotes · 0 comments

## Summary

A follow-up tutorial demonstrates how to fully implement a custom ModelBinder in ASP.NET MVC Preview 5 so that action methods can accept complex objects (like a Person) as parameters instead of primitive types. It covers utility functions for binary serialization, a PersonBinder class overriding ConvertType, registering the binder in Global.asax.cs, a view rendering a serialized Person into a hidden field, and an action method that receives the deserialized Person object. Full source code is provided as a downloadable zip.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.maartenballiauw.be/posts/2008-10-02-using-the-aspnet-mvc-modelbinder-attribute-second-part>

## Questions this post answers

### How do I create a custom ModelBinder in ASP.NET MVC to bind a complex object like Person as an action parameter?

Create a class that inherits DefaultModelBinder and override ConvertType to check if the destination type matches your object, then deserialize the incoming string (or first element of a string array) into that object. Register the binder in Global.asax.cs using ModelBinders.Binders.Add(typeof(Person), new PersonBinder()). The action method can then accept a Person parameter directly instead of an id.

_daily.dev surfaces practical walkthroughs like this for developers wiring up custom model binding in MVC apps._

### Why does my ASP.NET MVC ModelBinder ConvertType method receive a string array instead of a string?

The value passed into ConvertType can arrive as an array of strings rather than a plain string, so code must check if the value is a string[] and extract the first element before deserializing. Failing to handle this case causes a cast exception when the framework passes form data as an array type.

_developers debugging model binder edge cases often track these gotchas on daily.dev._

## Similar posts on daily.dev

- [ASP.NET Core Controllers: A Practical Guide to Building REST Endpoints](https://daily.dev/posts/asp-net-core-controllers-a-practical-guide-to-building-rest-endpoints-qbrdx5rqi) · We Are .NET · 0 upvotes · 0 comments

---

Tags: [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Using the ASP.NET MVC ModelBinder attribute - Second part","url":"https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv"},"datePublished":"2026-10-04T13:06:17.721Z","dateModified":"2026-10-04T13:13:52.534Z","description":"A follow-up tutorial demonstrates how to fully implement a custom ModelBinder in ASP.NET MVC Preview 5 so that action methods can accept complex objects (like...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/52f3e091e9e2482884f565012e08c878?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/52f3e091e9e2482884f565012e08c878?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Maarten Balliauw","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Maarten Balliauw","logo":"https://media.daily.dev/image/upload/s--rOTg3VYO--/f_auto,q_auto/v1791119043/logos/maartenballiauw?_a=BAMAMicg0","url":"https://daily.dev/sources/maartenballiauw"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c#","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Maarten Balliauw","item":"https://daily.dev/sources/maartenballiauw"},{"@type":"ListItem","position":3,"name":"Using the ASP.NET MVC ModelBinder attribute - Second part"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/using-the-asp-net-mvc-modelbinder-attribute---second-part-gtg1grgcv#faq","mainEntity":[{"@type":"Question","name":"How do I create a custom ModelBinder in ASP.NET MVC to bind a complex object like Person as an action parameter?","acceptedAnswer":{"@type":"Answer","text":"Create a class that inherits DefaultModelBinder and override ConvertType to check if the destination type matches your object, then deserialize the incoming string (or first element of a string array) into that object. Register the binder in Global.asax.cs using ModelBinders.Binders.Add(typeof(Person), new PersonBinder()). The action method can then accept a Person parameter directly instead of an id. daily.dev surfaces practical walkthroughs like this for developers wiring up custom model binding in MVC apps."}},{"@type":"Question","name":"Why does my ASP.NET MVC ModelBinder ConvertType method receive a string array instead of a string?","acceptedAnswer":{"@type":"Answer","text":"The value passed into ConvertType can arrive as an array of strings rather than a plain string, so code must check if the value is a string[] and extract the first element before deserializing. Failing to handle this case causes a cast exception when the framework passes form data as an array type. developers debugging model binder edge cases often track these gotchas on daily.dev."}}]}
```

