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

后端 未结 21 2220
野的像风
野的像风 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:30

    Set the property of System.Web.MVC,Copy Local = True

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

    What worked for me was closing Visual Studio, deleting the user option files (both solution and project level), then relaunching Visual Studio.

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

    I'm using dotnet core sdk 2.2 and Visual Studio Professional 2019.

    This was caused by Visual Studio mangling code.

    Code was pasted into the razor view. Visual Studio would attempt but then fail to auto-format it. Part of the failure resulted in deleting code.

    Pressing ctrl+z reverted the formatting but kept the pasted code. The razor compilation errors were then fixed (The name 'Html' does not exist in the current context)

    Disable format on paste (see https://stackoverflow.com/a/28053865/1462295 ) under Tools -> Options -> Text Editor -> HTML -> Advanced

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