“The name 'HTML' does not exist in the current context” in MVC 3 Views

后端 未结 21 2219
野的像风
野的像风 2020-12-15 03:50

I´m starting to use \"MVC 3\" but I´m facing some little problems. In my Views, when I code something like this:

@if(Request.IsAuthenticated) {
    

        
相关标签:
21条回答
  • 2020-12-15 04:11

    All you need to do is Restart Visual Studio and check.

    0 讨论(0)
  • 2020-12-15 04:13

    You could try:

    1. Close the View with the false errors.

    2. Close Visual Studio

    3. Reopen the same project

    4. Open a different View then the one causing the errors

    5. Close that View, hopefully you didn't see any of the similar errors in this View

    6. Reopen the View that gave you problems earlier

    0 讨论(0)
  • 2020-12-15 04:15
    <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    

    solution for this problem in web.config

    0 讨论(0)
  • 2020-12-15 04:16

    I experienced this on ASP.NET MVC 4 as well, after uninstalling EntityFramework from my packages list.

    I had to remove this section

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, ....

    that's left on the Web.config file... at the least it removed the errors from the errors list

    0 讨论(0)
  • 2020-12-15 04:16

    Apologies for the necro post.

    Selecting "Build | Rebuild Solution" corrected this issue for me in Visual Studio 2015. In my case, the warnings occurred after renaming the primary namespace of a project. A rebuild set everything straight.

    0 讨论(0)
  • 2020-12-15 04:16

    I got the same error once but it fixed when I changed one of my variables in the Model from non-nullable to nullable. Give it a try.

    0 讨论(0)
提交回复
热议问题