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

后端 未结 20 2210
-上瘾入骨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:10

    It took me ages to solve this issue, but finally I hope I have solved it on MVC, that is similar:

    I have reinstall ASP.NET 4.5 (http://www.asp.net/downloads)

    I have followed the upgrading tutorial on http://www.asp.net/whitepapers/mvc4-release-notes

    BUT this mentioned paragraph is wrong for me

    System.Web.Mvc, Version=4.0.0.0
    System.Web.WebPages, Version=2.0.0.0
    System.Web.Helpers, Version=2.0.0.0
    System.Web.WebPages.Razor, Version=2.0.0.0
    

    Because I have Razor in System.Web.Razor, so I changed the razor namespace to System.Web.Razor.

    Add this to your web.config

    
      
    
    

    I have add the assembly reference to all these assemblies above

    Locate the ProjectTypeGuids element and replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}.

    That is all.

提交回复
热议问题