MVC2 を使用してこのプロジェクトを開始しましたが、MVC3 dll に変更しました。
Asset エンティティがあります。コントローラーでは、次のように定義された Details ActionResult があります:
編集: (正しいコントローラーコードを入れてください。)
public ActionResult Details(int id)
{
using (var db = new AssetsContainer())
{
return View(db.Assets.Find(id));
}
}
私の Details.aspx ページは次のように定義されています。
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<CITracker.Models.Asset>" %>
<%@ Import Namespace="CITracker.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Details
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Details</h2>
<fieldset>
<legend>Fields</legend>
<div class="display-label">Id</div>
<div class="display-field"><%: Model.Id %></div>
次のエラーが表示されます。
CS1061: 'object' does not contain a definition for 'Id' and no extension method 'Id' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
これが MVC2 で機能していたのに、MVC3 で失敗した理由はありますか? 開発時エラーは発生しませんが、実行時エラーは発生します。