简体   繁体   English

MVC 5剃须刀代码-不包含定义

[英]MVC 5 razor code - does not contain a definition

I have a .cshtml file in my App_Templates folders that builds but I have heaps of errors. 我的App_Templates文件夹中有一个.cshtml文件,但该文件有很多错误。

I get it saying things like: 我得到这样说:

  • The name 'Model' does not exist in the current context 名称“模型”在当前上下文中不存在
  • The name 'ViewBag' does not exist in the current context 名称“ ViewBag”在当前上下文中不存在
  • HtmlHelper does not contain a definition for 'TextBoxFor' and no extension method for 'TextBoxFor' accepting a... HtmlHelper不包含'TextBoxFor'的定义,也没有'TextBoxFor'的扩展方法,接受...

It is strange because other cshtml files in other directories are fine and have no red line errors. 这很奇怪,因为其他目录中的其他cshtml文件都很好,并且没有红线错误。 I have restarted VS, restarted my PC, tried adding a few assembly lines from other questions and rebuilding. 我重新启动了VS,重新启动了PC,尝试从其他问题中添加一些装配线并进行重建。 I have tried for the past day but can't fix this annoying thing. 在过去的一天里,我尝试了一下,但无法解决此烦人的事情。

Any helpful hints or tips would be great. 任何有用的提示或技巧都很好。 If you require any specific information please let me know and i'll edit this post. 如果您需要任何特定信息,请告诉我,我将对此帖子进行编辑。

Just wanted to close this thread for good. 只是想永久关闭此线程。

The issue was as @Georg Patschieder suggested in the comments on the initial questions. 正如@Georg Patschieder在最初问题的评论中所建议的那样。 The wrong folder was used and once I moved the *.cshtml files to App_Code and changed the respective references everything worked great. 使用了错误的文件夹,一旦我将* .cshtml文件移动到App_Code并更改了各自的引用,一切都将正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM