Razor compilation error using NancyFX

I am creating a black jack program in C # using Nancyfx and the Razor viewer in Visual Studio 2012. Intelisense visual studios work, but I get these Razor compilation errors. I tried to specify the namespace in app / web.config without any results.

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>
+5
source share
1 answer

Please look again at your web.config and make sure that you have the razor settings set.

You will need the following:

<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>

Further explained here - https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine

+12
source

All Articles