Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:16:30+00:00 2026-06-04T06:16:30+00:00

I am using the recently released MVC 4 Beta (4.0.20126.16343) and am working on

  • 0

I am using the recently released MVC 4 Beta (4.0.20126.16343) and am working on getting around a known problem with deserialization/model binding not working with arrays (see Stack Overflow here)

I am having difficulty getting my explicit custom binding to hook up. I have registered a custome IModelBinder (or attempted to) but when my post action is called my custom binder isn’t hit and I just get the default serialization (with the null arrays – even though wireshark shows me the incoming complex object contains array elements).

I feel like I am missing something and would greatly appreciate any solution or insight.

Thanks.

from global.asax.cs:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapHttpRoute(
        name: "DefaultApi",
        routeTemplate: "api/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional }
    );

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
}

protected void Application_Start()
{
    ModelBinders.Binders.Add(typeof(DocuSignEnvelopeInformation), new DocusignModelBinder());
    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    BundleTable.Bundles.RegisterTemplateBundles();
}

and my custom binder:

public object BindModel(ControllerContext controllerContext, System.Web.Mvc.ModelBindingContext bindingContext)
{
    var value = bindingContext.ValueProvider.GetValue("envelope");

    var model = new DocuSignEnvelopeInformation();

    //build out the complex type here

    return model;
}

and my controller is just:

public void Post(DocuSignEnvelopeInformation envelope)
{
    Debug.WriteLine(envelope);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:16:31+00:00Added an answer on June 4, 2026 at 6:16 am

    This is what I ended up doing (thanks to Jimmy Bogard in Model binding XML in ASP.NET MVC 3)

    I wound my solution back to MVC 3. (Burned by pre-release anxiety once again)

    Added a ModelBinderProvider:

    public class XmlModelBinderProvider : IModelBinderProvider
    {
        public IModelBinder GetBinder(Type modelType)
        {
            var contentType = HttpContext.Current.Request.ContentType;
    
            if (string.Compare(contentType, @"text/xml",
                StringComparison.OrdinalIgnoreCase) != 0)
            {
                return null;
            }
    
            return new XmlModelBinder();
        }
    }
    

    and a ModelBinder

    public class XmlModelBinder : IModelBinder
    {
        public object BindModel(
            ControllerContext controllerContext,
            ModelBindingContext bindingContext)
        {
            var modelType = bindingContext.ModelType;
            var serializer = new XmlSerializer(modelType);
    
            var inputStream = controllerContext.HttpContext.Request.InputStream;
    
            return serializer.Deserialize(inputStream);
        }
    }
    

    and added this to Application_Start():

        ModelBinderProviders.BinderProviders
        .Add(new XmlModelBinderProvider());
    

    My controller stayed exactly the same as in the question.

    Works like a treat. Will be great when the new ‘no strings’ approach arrives properly with MVC 4, but this manual binding approach to deserialization isn’t exactly onerous.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen the experimental API for using Bluetooth has been recently released and I
I recently started using rspec and factory_girl and I'm working on a basic control
We recently started using AnkhSVN subversion plugin for Visual Studio. Everything is working as
I'm working on my own open-source project. I've recently released the first workable version
I have recently released an app on Google play see here When using Google
Visual Studio 11 Beta version is released recently. I'm to download and replace my
I'm using asp.net mvc 3 with jquery unobtrusive validation. I recently changed from standard
I recently ran into a problem with a COM object that was using a
Recently I released an app into Android Market using the licensing system with the
we've recently started using TFS2010 for source control. It's working well with the first

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.