如何使剃刀视图引擎使用 c# 6.0 [英] How to make razor view engine to use c# 6.0

查看:25
本文介绍了如何使剃刀视图引擎使用 c# 6.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我的 razor 视图引擎抛出错误并显示请使用语言版本 6 或更高版本".这可能只是给我一个提示.但是我如何让剃刀使用 c# 6.0.我在 cs 文件中的其余解决方案我可以使用所有新版本 7 功能.

Currently my razor view engine throws and error saying "Please use language version 6 or higher". That may just be resharper giving me a pointer. But how do i make razor use c# 6.0. Rest of my solution in the cs files i can use all the new version 7 features.

推荐答案

我相信这是由于 web.config 的模板中的一个错误,当项目升级到更新版本的.net 框架.

I believe this is due to a bug in the templates for web.config when the project is upgraded to a newer version of the .net framework.

我可以通过进入 web.config,找到 system.codedom 节点并将内容更改为如下所示来解决此问题:

I was able to fix this by going in to web.config, finding the system.codedom node, and changing the content to look like this:

<compilers>
  <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
  <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=&quot;Web&quot; /optionInfer+" />
</compilers>

这篇关于如何使剃刀视图引擎使用 c# 6.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆