The name 'model' does not exist in current context in MVC3

后端 未结 20 2205
-上瘾入骨i
-上瘾入骨i 2020-11-29 02:53

I added a cshtml page in an project. When I tried to add the following declaration to it, I get an error: \"The name \'model\' does not exist in current context\".



        
20条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 03:14

    If your views are in a class library assembly, which is useful for reuse of shared views among projects, then just doing what Adam suggests might not be enough. I still had issues even with that.

    Try this in your web.config in the root of your project:

    
    
      
        
          

    And this in the web.config in your views folder:

    
    
    
      
        
          

    This worked for me. I now have intellisense and no compile errors on my views in a non-MVC project that I can then reference from multiple MVC websites.

提交回复
热议问题