简体   繁体   English

可选和命名参数,MVC2中的语言规范

[英]Optional and named parameters, language specification in MVC2

I'm using MVC2 in a mixed webforms project, my Model classes compile fine with optional and named parameters, but my view won't compile when using them. 我在混合Webforms项目中使用MVC2,我的Model类可以使用可选参数和命名参数很好地编译,但是使用它们时,我的视图无法编译。 I get: 我得到:

Error 38 Feature 'named argument' cannot be used because it is not part of the 3.0 C# language specification 错误38无法使用功能“命名实参”,因为它不是3.0 C#语言规范的一部分

Any ideas? 有任何想法吗? Thanks 谢谢

Your app will need to be configured to run in ASP.NET 4.x rather than 2.x; 您的应用需要配置为在ASP.NET 4.x(而不是2.x)中运行; you might also want (in your web.config): 您可能还想要(在您的web.config中):

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v4.0" />
        <providerOption name="WarnAsError" value="false" />
      </compiler>
    </compilers>
  </system.codedom>

You might get away without this if you pre-compile your views. 如果您预先编译了视图,则可能会在没有此情况的情况下走开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM