Razor Views not seeing System.Web.Mvc.HtmlHelper

后端 未结 22 1111
我在风中等你
我在风中等你 2020-11-27 05:27

I am in the process of upgrading to MVC4. I have followed the instructions at http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806 but in my Razor views and layou

22条回答
  •  Happy的楠姐
    2020-11-27 06:03

    I tried all the solutions here but none of them worked for me. Again, my site runs fine but I don't have intellisense and get red wavy lines under a lot of things in my views that Visual Studio does not recognize, one of them being Html.BeginForm(), as well as anything having to do with ViewBag.

    I'm working with a new MVC 5 project. After hours of comparing web.config lines, I finally found what fixed it for me.

    My web.config in my root had the following line:

    
      
    
      
    
    

    I compared to a previous project not using MVC 5, and copied over a block I noticed was missing from the new one, which was the following:

    
      
        
          
          
          
          
          
        
      
    
      
    
    

    I copied the above block over to my new project's web.config in the root, changing the versions to match the numbers for each assembly found in my project references (right-clicking each reference mentioned and selecting "Properties", "Version" is given at the bottom of the properties window for the selected reference).

    After implementing the above, I now have intellisense and don't get any unknown red lines under things like Html.BeginForm, ViewBag.Title, etc.

提交回复
热议问题