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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:53:06+00:00 2026-05-31T10:53:06+00:00

I recently found that if i said: object latestPosts = new MyApp.Models.LatestPosts(); TryUpdateModel(latestPosts); The

  • 0

I recently found that if i said:

object latestPosts = new MyApp.Models.LatestPosts();
TryUpdateModel(latestPosts);

The latestPosts object does not update. This is due to an issue found here. Using the workaround solved the issue. However if i move latestPosts to be a property (called Parameters) of an existing type (e.g. Widget) it doesn’t update the model. E.g.

var widget = new Widget();
MyTryUpdateModel(widget, "Widget", null, null, ValueProvider); // LatestPosts doesn't update

But the following does work:

MyTryUpdateModel(widget.Parameters, "Widget.Parameters", null, null, ValueProvider);

Edit: Here’s the Widget class:

public class Widget {        
    [Required, StringLength(100)]
    public virtual string Name { get; set; }

    private object _parameters;
    public virtual object Parameters {
        get {
            // Code removed for brevity
            if (_parameters == null)
                _parameters = new MyApp.Models.LatestPosts();

            return _parameters;
        } set { _parameters = value; }
    }
}

And here’s the LatestPosts class:

public class LatestPosts {
    public int NumPosts { get; set; }
}

I can’t see why the initial MyTryUpdateModel didn’t work for updating the whole of the Widget since it should handle complex types. I’d appreciate it if someone could shed some light on this issue.

Thanks

  • 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-31T10:53:08+00:00Added an answer on May 31, 2026 at 10:53 am

    I will explaim both why the original TryUpdateModel doesn’t work and why the “patched TryUpdateNode doesn’t work in your case. I am the coordinator of the Mvc Controls Toolkit that contains a complex custom Model Binder, so we acquired a deep knowledge of Model Binder and of the problems behind it.

    Default TryUpdateModel: it just invoke the DefaultModelBinder. Now determining the type at runtime based on information gained during the model binding process is risky, because such information come from the client and might be manipulated by a malicious user that, this way, might force the model binder to create an instance of a Type he decided….very risky…He might exploit this to force model binder to execute unwanted malicious code that is in the constructor of the “fake” type. So the general design choice is that ALL TYPES used by the model binder MUST BE DETERMINED AT COMPILE TIME

    MyTryUpdateModel: it just determine the type of the root model by calling GetType, and then use this information to invoke the default model binder on this type. However, with the exception of this initia “startup” the Model Binder works as usual ….that is…the type of the properties of the root model, IS NOT OBTAINED WITH GetType or with runtime infos, but by just inspecting the type of the property of the root model…that in your case is object…that means no information.

    The defaul custom model binder of the Mvc Controls Toolkit has tools for determining the type at runtime…but not ALL TYPES..because thi expose at risks of attcks…types that are subtypes of “safe” types..for instance types that implement an Interface.

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

Sidebar

Related Questions

I have recently found out that Smarty, differently from Django template engine, does not
I recently found an article online that told me about this: RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2
I recently found this post . It basically says that Eclipse has a modified
I've recently found this blog entry on a tool that writes XSS attacks directly
I recently found out over the weekend that iframes are not valid in XHTML
I recently found that this is impossible in SQLite: SELECT * FROM fruit WHERE
I recently found that dropdownlist events are not shown in properties window. I was
I am a windows dev, but I have recently found that I need to
I have recently found out that there exists a method called nth_element in the
I have recently found out that no argument constructor and multiple argument constructor cannnot

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.