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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:59:22+00:00 2026-05-19T12:59:22+00:00

Since I upgraded from MVC 2 to MVC 3 RC, using TryUpdateModel causes a

  • 0

Since I upgraded from MVC 2 to MVC 3 RC, using TryUpdateModel causes a NullReferenceException. This problem only occurs when running my action method as part of a unit test. Running it on the actual server works as expected.

Here’s a stack trace of the exception:

System.NullReferenceException: Object
reference not set to an instance of an
object. at
System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext
controllerContext) at
System.Web.Mvc.ValueProviderFactoryCollection.<>c_DisplayClassc.b_7(ValueProviderFactory
factory) at
System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at
System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()
at
System.Collections.Generic.List1..ctor(IEnumerable1
collection) at
System.Linq.Enumerable.ToList[TSource](IEnumerable`1
source) at
System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext
controllerContext) at
System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel
model, String prefix)
… my own code from here on….

In case it matters, my controller has the following signature:

[AcceptVerbs(HttpVerbs.Post)]
public virtual ActionResult Edit(int id, FormCollection collection)
{
}

My guess is that this has to do with the new way DI works in MVC3, but I can’t figure out what I’m doing wrong. Perhaps there is something in terms of DI setup that is required in MVC 3, but wasn’t required in MVC 2?

  • 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-19T12:59:23+00:00Added an answer on May 19, 2026 at 12:59 pm

    In case someone else has the same problem and finds this post:

    I solved the problem generically based on Ivan Kortym’s answer (thanks!), with the following piece of code in my controller base class constructor:

    if (Request!=null && Request.Form != null && Request.Form.HasKeys() && ValueProvider == null)
    {
        ValueProvider = new FormCollection(Request.Form).ToValueProvider();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been encountering this problem since I last upgraded PhoneGap from 1.3.0 to 1.4.1,
We've been dealing with a problem with our event gateways since we upgraded from
I have been using this for a while, but have since then upgraded to
I have a c# Mono MVC application. Since I upgraded to Ubuntu 11.10 (from
We have a problem in our swing based application since we've upgraded our java
Since I have upgraded from VS2008 to VS2010, I've been having an increasingly infuriating
Ever since I upgraded my Ubuntu from 9.10 to 10.04 I can't start Netbeans
I recently upgraded from Emacs 23 to Emacs 24. Since the upgrade, it seems
Upgraded from MVC Beta to MVC RC1. Re-pointed all references in the project to
I have upgraded Windows XP - PC RAM from 1GB to 3GB. Since JVM

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.