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 579515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:22:30+00:00 2026-05-13T14:22:30+00:00

First of all some context : I have a form, where I post back

  • 0

First of all some context:

I have a form, where I post back some objects that are automatically materialized into objects by MVCs built-in ModelBinder:

<input type="hidden" name="myobj[0].Id" />
<input type="text" name="myobj[0].Hours" />
<input type="hidden" name="myobj[1].Id" />
<input type="text" name="myobj[1].Hours" />

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Save(IList<MyObject> myobj);

Additionally: I would like to stress that we are posting to DTO (DataTransferObjects) that we further down the line map into entity framework entities, so we would rather not like the change anything on the DTO’s except maybe adding attributes.

Problem

If a user enters an invalid value for “Hours”, say ‘Fubar’, then the ModelBinder naturally will not attempt to set the ‘Hours’-property. But it defaults to 0, because it is an int and not a string.

This causes some difficulty for me ofcourse, because now I can’t see if the user actually entered 0, or if this was caused by invalid input.

Since I am using a home-rolled object-to-entity (Entity Framework) mapper, we cannot change the foot-print of the ‘Hours’-property to int?. I am aware that MVC has some built in Validation, but we would rather not implement that since we know it has been wildly attacked and that there is some new validation coming in ASP.NET MVC 2.0.

Solution?

I need to be able to point out to the user which field is incorrect, so that means I somehow need to be able to catch an exception (or possibly some other ingenious solution?), where I can do some logic and post back a new view to the user where I clarify what they did incorrectly.

My current idea: Writing a custom ModelBinder.

What do you suggest?

  • 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-05-13T14:22:31+00:00Added an answer on May 13, 2026 at 2:22 pm

    This causes some difficulty for me ofcourse, because now I can’t see if the user actually entered 0, or if this was caused by invalid input.

    Yes you can. Look in the ModelState.

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

Sidebar

Related Questions

First of all, apologize because I have seen some posts about this, but I
First of all, it needs to create some codes that handle any error in
I have some content that contains a token string in the form $string_text =
first of all some details: I configured security as below in web.xml view plaincopy
First of all, I did some search and no answer on stackoverflow/google provided me
First of all thank you for your time and sorry if some issues are
First of all, I did some searching for an answer to this question...but I
first of all, my main question: What are some good troubleshooting techniques when you
First of all, sorry for my English. I need some help with this. Recently
First of all, I'm new to objective-c programming so I've probably made some mistakes

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.