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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:29:06+00:00 2026-05-27T13:29:06+00:00

UPDATE: Problem Solved. Darin Dimitrov’s answer contains a link to another, related question. One

  • 0

UPDATE: Problem Solved.

Darin Dimitrov’s answer contains a link to another, related question. One of the proposed solutions on that page ended up working for us.


Original Question

The code sample below works in MVC 2 but throws an exception in MVC 3. Does anyone know why MVC 3 introduced this breaking change? Is there a way to get this working in MVC 3 while still allowing me to describe the viewmodel as an Interface from within the view?

There is another related question on StackOverflow, but it doesn’t give me any info as to why there is a difference between MVC 2 and MVC 3.

Model

public interface IPerson {
    string Name { get; set; }
}

public interface ISpy : IPerson {
    string CodeName { get; set; }
}

public class Spy : ISpy {
    public string Name { get; set; }
    public string CodeName { get; set; }
}

Controller Action

public ActionResult Index() {
    var model = new Spy { Name = "James Bond", CodeName = "007" };
    return View(model);
}

MVC2 View (Works perfectly)

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MvcApp.Models.ISpy>" %>
<p>CodeName: <%: Html.TextBoxFor(x => x.CodeName) %></p>
<p>Name: <%: Html.TextBoxFor(x => x.Name) %></p>

MVC3 View (Throws exception)

@model MvcApp.Models.ISpy
<p>Name: @Html.TextBoxFor(x => x.Name)</p>
<p>CodeName: @Html.TextBoxFor(x => x.CodeName)</p>

MVC3 Exception Information

I am showing the relevant exception info below, but you can view the entire output of the error page here: https://gist.github.com/1443750.

Runtime Exception
System.ArgumentException: The property **`MvcApp.Models.ISpy.Name`** could not be found.

Source Error:

Line 1:  @model MvcApp.Models.ISpy
Line 2:  <p>CodeName: @Html.TextBoxFor(x => x.CodeName)</p>
Line 3:  <p>Name: @Html.TextBoxFor(x => x.Name)</p>


Stack Trace:

[ArgumentException: The property MvcApp.Models.ISpy.Name could not be found.]
   System.Web.Mvc.AssociatedMetadataProvider.GetMetadataForProperty(Func`1 modelAccessor, Type containerType, String propertyName) +502169
   System.Web.Mvc.ModelMetadata.GetMetadataFromProvider(Func`1 modelAccessor, Type modelType, String propertyName, Type containerType) +101
   System.Web.Mvc.ModelMetadata.FromLambdaExpression(Expression`1 expression, ViewDataDictionary`1 viewData) +421
   System.Web.Mvc.Html.InputExtensions.TextBoxFor(HtmlHelper`1 htmlHelper, Expression`1 expression, IDictionary`2 htmlAttributes) +58
   System.Web.Mvc.Html.InputExtensions.TextBoxFor(HtmlHelper`1 htmlHelper, Expression`1 expression) +50
   ASP._Page_Views_Home_Index_cshtml.Execute() in c:\Projects\MvcApplication1\MvcApplication1\Views\Home\Index.cshtml:3

Help us Darin Dimitrov, you’re our only hope.

  • 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-27T13:29:07+00:00Added an answer on May 27, 2026 at 1:29 pm

    I have already brought this issue to the attention of Microsoft. Unfortunately the response I got was: sorry that’s by design. Personally the conclusion I draw from such an answer is that the MVC team is designing a buggy product if that’s by design. And they are not to be blamed for taking such a design decision, they are for blaming for not mentioning it anywhere in the breaking changes section of the release notes document. Had they mentioned it, then it would have been our fault when we took the decision for migrating even if we deliberately knew about the breaking change.

    Anyway, here’s a related question.

    And here’s an answer from the MVC team:

    Unfortunately, the code was actually exploiting a bug that was fixed,
    where the container of an expression for ModelMetadata purposes was
    inadvertently set to the declaring type instead of the containing
    type. This bug had to be fixed because of the needs of virtual
    properties and validation/model metadata.

    Having interface-based models is not something we encourage (nor,
    given the limitations imposed by the bug fix, can realistically
    support). Switching to abstract base classes would fix the issue.

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

Sidebar

Related Questions

UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:
The problem is not solved although I accepted one answer. Problem: Vim updates very
Update II Problem Solved but Why? This has been the biggest headache ever. My
The problem: I often have to update two or more repositories: One for the
EDIT: Update - scroll down EDIT 2: Update - problem solved Some background information:
Update: When I use the subprocess.call instead of subprocess.Popen , the problem is solved
Update: Problem solved, and staying solved. If you want to see the site in
Problem solved: Thanks guys, see my answer below. I have a website running in
Update: Problem solved . I have to call a web service method (dduLogin), which
[Update: Problem solved! See bottom of the post] I need to allow python developers

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.