Nancy, First razor page not working

三世轮回 提交于 2020-01-13 13:31:40

问题


I'm trying to get a first Razor template working with Nancy, and the first line of my .cshtml...

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>

gives me 3 build errors including the following...

'NancyContext' does not contain a definition for 'ApplicationInstance' and no extension method 'ApplicationInstance' accepting a first argument of type 'NancyContext' could be found (are you missing a using directive or an assembly reference?)

One very weird thing is that I have three "errors", but they're not stopping the build. They show in the Error list, the classes are underlined in red in the Solution explorer but not in the code window. Don't believe me ? Screenshot follows...

Update

I've fixed the first two errors by adding explicit references to System.Web.Helpers and System.Web.WebPages. The remaining error, 'NancyContext' does not contain a definition for 'ApplicationInstance', is still bugging me. ApplicationInstance is a type in System.Web, for which I have a reference. If I delete the System.Web reference the project still builds. If I add the reference I still have the error.


回答1:


I got the same error today and then noticed that the project was getting build in "Build + IntelliSense" mode (as in your screenshot), going to the dropdown their and building in "Build Only" mode resolved my errors!




回答2:


All I can say is that ApplicationInstance is not a Nancy type. Perhaps you are missing a namespace or assembly include? https://github.com/NancyFx/Nancy/wiki/Razor-View-Engine

Other than that, you are going to have to share a lot more information or there's not much to go on



来源:https://stackoverflow.com/questions/36353303/nancy-first-razor-page-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!