Red lines under ViewBag and HTML.TextboxFor helpers in Views

北城余情 提交于 2020-01-06 08:18:06

问题


I have installed Visual Studio 2012 that comes with MVC4, and opened a project done in MVC3.

On my views, all references to:

ViewBag.<Property>

Showed the red waved lines, saying "dynamic library missing", and

HTML.TextBoxFor(m => m.Property)
HTML.HiddenFor(m => m.Property)
etc...

Showed error "arguments cannot be inferred from usage".

I found the answered in other no-related thread, so I'm opening this question here to help others, as I didn't find it in Google looking for the main topic. Below the answer.


回答1:


In the web.config file :

<compilation debug="true>

change it to:

<compilation debug="true" targetFramework="4.0">

Thanks to Jim that posted a tiny comment on this Question




回答2:


I tried troubleshooting this similar issue for hours. Red lines under all @Html helpers. Everything I read on SOF and other sites would not work. The web app would compile and run fine.

The way I fixed my issue was by uploading all my code to my Visual Studio Online environment. Delete the project folder/solution on my local machine. Close Visual Studio. Open Visual Studio. Connect to team explorer and do a get latest from the source control explorer.

Finally, go to File > Open > Project within VS and open the project .sln file.

All the red lines and visual studio cache/temp files are cleaned up.




回答3:


Here is the answer:

In your Web.Config file make sure that the compilation target framework matches the httpRuntime target framework version e.g.:

<system.web>
    <authentication mode="None"/>
    <compilation debug="true" targetFramework="4.6.1"/>
    <httpRuntime targetFramework="4.6.1"/>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
  </system.web>


来源:https://stackoverflow.com/questions/13695497/red-lines-under-viewbag-and-html-textboxfor-helpers-in-views

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!