我在这里发现了一个类似的问题: Razor View Engine : An expression tree may not contain a dynamic operation
但是我已经尝试了解决方案,但它们并没有解决我的问题。我有一个具有以下内容的控制器:
public ActionResult CreateOrganization(Guid parentOrganizationId)
{
Organization organization = new Organization();
return View(organization);
}
该视图具有以下内容:
@using Project.Data
@Model Project.Data.Organization
@{
ViewBag.Title = "Create new Organization";
}
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>Use the form below to create a new Organization.</h2>
</hgroup>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
@using (Html.BeginForm((string)ViewBag.FormAction, "Organization"))
{
<fieldset>
<legend>Create Organization</legend>
<ol>
<li>
@Html.LabelFor(m=> m.Name)
@Html.TextBoxFor(m=> m.Name);
@Html.ValidationMessageFor(m=> m.Name)
</li>
</ol>
<input type="submit" value="Register" />
</fieldset>
}
这是明确指定模型(如另一篇文章中所建议)。但是,我仍然收到“表达式树可能不包含动态操作”错误。我在某个地方犯了一个愚蠢的错误吗?