剃刀查看投掷"名称'模式“不会在目前的情况下&QUOT存在; [英] Razor View throwing "The name 'model' does not exist in the current context"
问题描述
我只是做了一堆重构在我的MVC 4应用,而现在,我试图去通过和调试我的看法,剃刀给我这个荒谬的错误:
I just did a bunch of refactoring throughout my MVC 4 application, and now that I'm trying to go through and debug my Views, Razor is giving me this nonsensical error:
The name 'model' does not exist in the current context.
这使得从字面上零感的部分是,这是导致错误:
The part that makes literally zero sense is that this is causing the error:
@model ICollection<DataSourceByActive>
我知道一个事实,即 @model
是正确的剃刀语法。
那么,为什么会出现这种情况?我怎样才能解决这个问题?
So why is this happening? How can I fix it?
编辑:这个问题被标记为的<一个副本href=\"http://stackoverflow.com/questions/6389055/the-name-model-does-not-exist-in-current-context-in-mvc3\">this问题,但我不认为它是。这里详细介绍这个问题的原因是在项目级别 Web.config中的错误配置,而上述问题细节在意见失踪的命名空间水平的Web.config。
This question was flagged as a duplicate of this question, but I don't think it is. The cause of the problem detailed here was misconfiguration of the project level Web.config, while the aforementioned question details missing namespaces in the views level Web.config.
的问题是不同的,在不同的使用情况各提供不同的目的,所以我不认为重复的问题,规则适用于这里。即便如此,这个问题是三十岁,拥有的其他问题的意见2/3 - 我几乎看到这个问题是不是证明有用
The issues are different and each serves distinct purposes in different use cases, so I do not think the duplicate question rule applies here. Even still, this question is three years old and has 2/3 of the views of the other question - I hardly see how this question is not proving useful.
推荐答案
我想你已经搞砸了它生活在浏览文件夹中的web.config文件。
I think you have messed up the web.config file which lives in the Views folder.
创建一个新项目瞄准同一个.NET框架和复制其查看/ web.config文件在顶部一个在当前项目
Create a new project targeting same .NET framework and copy its Views/web.config file over top the one in your current project
此外,Dudeman3000评论说:如果你在你的MVC项目区都富人视图\\ Web.config文件中呢!
Also, Dudeman3000 commented "if you have Areas in your MVC project they all haves Views\web.config files too!"
这篇关于剃刀查看投掷&QUOT;名称'模式“不会在目前的情况下&QUOT存在;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!