c# – 异常:表达式树可能不包含动态操作

我在这里发现了类似的问题:
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>
}

这是明确指定模型(如另一篇文章中所建议的).但是我仍然收到’表达式树可能不包含动态操作’错误.我在某个地方犯过一个愚蠢的错误吗?

您的视图似乎不正确.

模型声明应该是小写的“模型”,而不是“模型”:

@model Project.Data.Organization
相关文章
相关标签/搜索