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

  • Home
  • SEARCH
  • 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 9236909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:24:45+00:00 2026-06-18T07:24:45+00:00

I want to create a custom model binder in ASP.Net Web API. There are

  • 0

I want to create a custom model binder in ASP.Net Web API. There are plenty of resources on how to do this from scratch, but I want to leverage existing functionality.

I have looked around in the source on codeplex and can see plenty of modelbinders in there but most are sealed… and even then I can’t work out which one would be used in which situations.

Here is my api method header:

public async Task<HttpResponseMessage> Post(long appId, [FromBody]Field field)

What I want to do is basically intercept the modelbinder after it has populated all the basic properties, and then set some extra values based on http request headers that I’ll be setting on the client side.

As I say, I am comfortable with creating custom modelbinders and modelbinderproviders and wiring them in, the bit I’m having a problem with is trying to re-use the existing functionality provided.

Thanks, Pete

  • 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-18T07:24:46+00:00Added an answer on June 18, 2026 at 7:24 am

    Take a look here for the extension points for WebApi.

    There is no exact equivalent for MVC’s DefaultModelBinder in WebApi.

    If you are using the [FromBody] attribute then the FormatterParameterBinding will be invoked and a MediaTypeFormatter will be used to construct your model.

    The model binders for the URI path and Url (Query Params) will invoke ModelBinderParameterBinding which will pass on to either a IValueProvider or a IModelBinder…

    So…

    In your example Field (depending on the result of content type negotiation) will use one of these: XmlMediaTypeFormatter, JsonMediaTypeFormatter or FormUrlEncodedMediaTypeFormatter. It is therefore up to you to customise the serialisation behavior of these using their respective settings e.g. JSON.NET settings… or implement your own or wrapped MediaTypeFormatter.

    In your example the appId will probably be passed on to a IValueProvider… like ElementalValueProvider.

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

Sidebar

Related Questions

I want to create a custom asp.net mvc3 helper . To use that helper,
In my ASP.NET MVC 2 web application, I allow users to create custom input
i want create a custom json data from the mssql 2008 results so that
I want to create a custom property on one of my entities mapped from
I want to create a custom modelbinder which validates the bounded model. I have
I want to create custom validation for duplicate User name and E-mail. Model is
I want to create a custom finder (being a web development veteran but a
I want to create custom page for admin panel without model. For first i
I want to create custom button and I need it to be circle. How
I want to create a custom navigation bar to put in my header.phtml file.

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.