1

源代码...

事情是,如果我使用像这样的流利的模型元数据提供程序指定所需的元数据=>

public class Foo
    {
        public string Bar { get; set; }
    }

    public class FooModelMetadataConfiguration : ModelMetadataConfiguration<Foo>
    {
        public FooModelMetadataConfiguration()
        {
            Configure(x => x.Bar)
                .Required("lapsa") ;
        }
    }

并将其写入我的视图 =>

<% Html.BeginForm(); %>
<%= Html.ValidationSummary() %>
<%= Html.TextBoxFor(x=>x.Bar) %>
<% Html.EndForm(); %>

并将其添加到家庭控制器 =>

 [HttpPost]
 public ActionResult Index(Foo foo)
 {
       ViewData["Message"] = "Welcome to ASP.NET MVC!";

       return View(foo);
 }

它将输出这个 html =>

<div class="validation-summary-errors">
  <ul>
    <li>lapsa</li>
    <li>The Bar field is required.</li>
  </ul>
</div>

我不明白为什么会呈现第二个错误以及如何省略它。

System.Web.Mvc.Extensibility 框架的作者回复为 =>

我认为这是 asp.net mvc 的一个已知问题,我不记得我读过它的确切位置,我建议你在 asp.net mvc 问题跟踪器中通过 codeplex 发布这个问题。

但在我在问题跟踪器上发布任何内容之前 - 我想先了解到底是什么问题。

有什么帮助吗?

4

1 回答 1

0

现在已经修好了。

于 2010-03-09T08:02:11.327 回答