name 'html' nor name 'model' exist in current context in usercontrol MVC and C#

非 Y 不嫁゛ 提交于 2019-12-03 21:48:09
Dave Archer

This forum post has a potential solution to your problem:

Sometimes Intellisense doesn't show up in aspx/ascx/master files if there is a compilation error in the application. If you try running the site and you get a compilation error from ASP.NET, try fixing it and then see if it works.

If the app was previously using ASP.NET MVC Beta and you later changed it to use the fully released version then it's also quite likely that there's a configuration problem. Try comparing the two web.config files in the project (one in the root and one in the Views folder) and see if there are any differences between them.

SoftwareSavant

I had the same problem...

In my web.config file I had just the regular namespaces placed in the node...

    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />

Once I added this to my node the error went away...

pages validateRequest="false"
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <controls>
    <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
  </controls>

I hope this helps someone out. I was stuck for a couple of hours trying to figure this out.

<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
  <parameters>
    <parameter value="v11.0" />
  </parameters>
</defaultConnectionFactory>

Solution for this problem

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