ExistingUsers
MVC でコントローラーを作成しました:
public ActionResult ExistingUsers()
{
MembershipUserCollection users = Membership.GetAllUsers();
return View(users);
}
そして、上記のコントローラーの次のビュー:
@model MembershipUserCollection
@{
ViewBag.Title = "ExistingUsers";
}
<h2>ExistingUsers</h2>
<table>
<tr>
<th>
Username
</th>
<th>
CreationDate
</th>
<th>
Email
</th>
<th>
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.UserName)
</td>
<td>
@Html.DisplayFor(modelItem => item.CreationDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
<a href="/Account/DeleteUser?UserName=@item.UserName">Delete</a>
</td>
</tr>
}
}
</table>
しかし、コントローラーにリクエストを送信するたびに、例外が発生します。
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'object' does not contain a definition for 'UserName' and no extension method 'UserName' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 25: <tr>
Line 26: <td>
Line 27: @Html.DisplayFor(modelItem => item.UserName)
Line 28: </td>
Line 29: <td>
ここで何がうまくいかないのですか?