【问题标题】:Nancy doesn't render Model data on the view (VB.NET)Nancy 不在视图上呈现模型数据 (VB.NET)
【发布时间】:2018-11-24 15:47:59
【问题描述】:

我的应用程序是一个控制台应用程序 (VB.Net),它使用自托管 Nancy(使用 TopShelf)。

我可以完美地返回 html 视图,但我无法返回正确使用模型的视图.. html 页面只显示 @Model.whatever 而不替换它。

这是我的代码:

在 NancyModule 中:

        [Get]("dashboard/blank") = Function()

                                   Dim SimpleClass = New SimpleClass With {
                                            .Name = "John",
                                            .Any = "Smith"
                                        }

                                   Return View("webserver/dashboard/views/blank.html", SimpleClass)

                               End Function

模型:

   Public Class SimpleClass
        Public Property Name As String
        Public Any As String
    End Class

html页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Blank</title>

</head>
<body>

    <h1>Display @SimpleClass.Name</h1>
    <h1>Display @SimpleClass.Any</h1>

</body>
</html>

这是令人失望的输出:

【问题讨论】:

    标签: nancy


    【解决方案1】:

    原来我在 html 页面中犯了一个错误……Nancy 只会替换关键字“Model”(区分大小写)而不是任何名称..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-06
      • 2014-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多