我开始在Mono(Ubuntu)和
Nancy中学习C#,这是一个C#的Web框架.我正在使用他们的“超级简单视图引擎”渲染,我无法使代码呈现.sshtml文件,它只显示为计划文本文件.最终,我想使用布局文件(layout.sshtml),每个视图将替换部分布局文件.
我有预感,可能文件夹结构无效,例如login.sshtml找不到layout.sshtml.但是我修改了.csproj文件来复制Views文件夹:
- <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Debug' ">
- <!-- needed to deply views folder -->
- <Exec Command="cp -a Views $(OutDir)" />
- <!-- needed to deply database if not newer -->
- <Exec Command="cp -a -u Database/db.sqlite $(OutDir)" />
- </Target>
我只是为什么它不渲染视图感到困惑.任何帮助,将不胜感激.
This is the link to my repository
这是我项目的文件夹结构:
- ├── bin
- │ └── Debug
- │ ├── csharp-practice.exe
- │ ├── csharp-practice.exe.mdb
- │ ├── db.sqlite
- │ ├── Nancy.dll
- │ ├── Nancy.Hosting.Self.dll
- │ ├── nancy-simple-app.exe
- │ ├── nancy-simple-app.exe.mdb
- │ └── Views
- │ ├── index.sshtml
- │ ├── layout.sshtml
- │ ├── login.sshtml
- │ └── register.sshtml
- ├── Database
- │ ├── DataBaseManager.cs
- │ └── db.sqlite
- ├── LICENSE
- ├── nancy-simple-app.csproj
- ├── nancy-simple-app.sln
- ├── nancy-simple-app.userprefs
- ├── obj
- │ └── x86
- │ └── Debug
- │ ├── csharp-practice.csproj.FilesWrittenAbsolute.txt
- │ ├── csharp-practice.exe
- │ ├── csharp-practice.exe.mdb
- │ ├── nancy-simple-app.csproj.FilesWrittenAbsolute.txt
- │ ├── nancy-simple-app.exe
- │ └── nancy-simple-app.exe.mdb
- ├── packages
- │ ├── Nancy.1.4.3
- │ │ ├── lib
- │ │ │ └── net40
- │ │ │ ├── Nancy.dll
- │ │ │ └── Nancy.xml
- │ │ └── Nancy.1.4.3.nupkg
- │ ├── Nancy.Hosting.Self.1.4.1
- │ │ ├── lib
- │ │ │ └── net40
- │ │ │ ├── Nancy.Hosting.Self.dll
- │ │ │ └── Nancy.Hosting.Self.xml
- │ │ └── Nancy.Hosting.Self.1.4.1.nupkg
- │ └── repositories.config
- ├── packages.config
- ├── Program.cs
- ├── Properties
- │ └── AssemblyInfo.cs
- ├── viewmodels
- │ └── UserModel.cs
- └── Views
- ├── index.sshtml
- ├── layout.sshtml
- ├── login.sshtml
- └── register.sshtml
截图:
解决方法
找到解决方案,问题是在
Views folder中使用双引号而不是单引号
例如,改变这个:
- @Master["layout"]
- @Section["content"]
- This is content on the register page
- @EndSection
对此:
- @Master['layout']
- @Section['content']
- This is content on the register page
- @EndSection
我不知道为什么,但它解决了布局问题.
By the day,this is the link to working website,it just a simple login,logout,register website.