我正在使用 Nancyfx 和 Visual Studio 2012 中的 Razor 视图引擎在 C# 中创建一个黑杰克程序。Visual studios Intelisense 可以工作,但我收到这些 Razor 编译错误。我尝试在 app/web.config 中指定名称空间,但没有结果。
Error Details
Error compiling template: Views/Game.cshtml
Errors:
[CS0246] Line: 1 Column: 11 - The type or namespace name 'Black_Jack' could not be found (are you missing a using directive or an assembly reference?)
[CS0246] Line: 24 Column: 73 - The type or namespace name 'Black_Jack' could not be found (are you missing a using directive or an assembly reference?)
Details:
@using Black_Jack.Models
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Game>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
@{
foreach(var player in @Model.Players.players)
{
foreach(var card in player.Hand.Cards)
{
<p>@card.Name</p>
}
}
}
</body>
</html>
请再次查看您的 web.config 并确保您已定义剃刀设置。
您将需要以下内容:
<configSections>
<section name="razor" type="Nancy.ViewEngines.Razor.RazorConfigurationSection, Nancy.ViewEngines.Razor" />
</configSections>
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="MyAssemblyName" />
</assemblies>
<namespaces>
<add namespace="Black_Jack.Models" />
</namespaces>
</razor>
这里进一步解释 -https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)