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

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

提交回复
热议问题