asp.net-core - ValidationSummary.ModelOnly 失败,但 ValidationSummary.All 有效

标签 asp.net-core

这很奇怪。由于某种原因,这失败了:

<div asp-validation-summary="ValidationSummary.ModelOnly"></div>

但这个工作得很好:
<div asp-validation-summary="All"></div>

有谁知道为什么?这是整个代码片段:
<div class="row">
<div class="col-md-6 col-md-offset-3">
    <h3>Login</h3>
    <form method="post" novalidate>
        <div asp-validation-summary="All"></div>
        @*<div asp-validation-summary="ValidationSummary.ModelOnly"></div>*@
        <div class="form-group">
            <label asp-for="Username"></label>
            <input type="text" asp-for="Username" class="form-control" />
            <span asp-validation-for="Username"></span>
        </div>
        <div class="form-group">
            <label asp-for="Password"></label>
            <input type="password" asp-for="Password" class="form-control" />
            <span asp-validation-for="Password"></span>
        </div>
        <div class="form-group">
            <input type="submit" value="Login" class="btn btn-success" />
        </div>
    </form>
</div>

最佳答案

我假设您使用的是 asp.net core 1.0。验证摘要标签助手的值已从

<div asp-validation-summary="ValidationSummary.ModelOnly"></div>

简单地
<div asp-validation-summary="ModelOnly"></div>

你用 All 做了正确的事;-)

asp.net core docs

关于asp.net-core - ValidationSummary.ModelOnly 失败,但 ValidationSummary.All 有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38860473/

相关文章:

angular - 如何在 Vr 设备和 Angular 前端之间实现语音(以及更高版本的视频)聊天?

linux - 在 Linux 上使用 Docker 进行 Asp.Net 5.0 开发

c# - 使用 ExceptionHandler PipeLine 时,ASP.NET Core 返回 404 而不是 500

c# - 在 core 3.0 中将 View 渲染为字符串 : Could not find an IRouter associated with the ActionContext

c# - 在 ASP.NET Core 中实现 OrganizationUnit 过滤器

c# - 如何最好地在两个 ASP.NET Core 服务器应用程序之间进行通信?

c# - ASP.NET Core MVC 标记帮助器参数中的字符串文字

c# - 带有返回 null 的简单注入(inject)器的 ASP.NET Core 2.1 服务定位器

angular - 为 Angular 项目启用 Docker 支持

c# - 在 ASP.NET Core 应用程序中加载自定义 ConfigSection