Using “nameof” operator in Razor views

后端 未结 2 2067
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 03:21

On my VS.NET 2015 development machine, the Razor views that use the nameof operator work like a charm.

When deploying to a Windows server, it fails to compile the CSHTML

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 04:03

    According to this site, you need to reference the Roslyn compiler in your Web.config file to get C# 6 features to work in your razor views.

    This can be achieved simply by installing the CodeDOM Providers for .NET Compiler NuGet package.

    PM> Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    

提交回复
热议问题