gpt4 book ai didi

c# - 在哪里将 Razor 页面语言版本配置为 C# 6?

转载 作者:行者123 更新时间:2023-12-02 09:40:27 25 4
gpt4 key购买 nike

最近,我尝试在 ASP.NET MVC (5) .cshtml View 中使用一些 C# 6 新功能(插值字符串),但在运行时收到一条错误消息,提示 $ 。很明显,编译器处于 C# 5 兼容模式,或者最糟糕的是它是 C# 5 编译器。

在编辑器中时,会弹出警告警告我(我不知道是 VS 还是 ReSharper)“插值字符串”功能在 C# 5 中不可用。请使用语言版本 6 或更高版本。

项目本身设置为 C# 6,我可以在构建时编译的代码中使用 C# 6 功能,例如 Controller 等。

问:我应该在哪里设置页面编译器版本,当我将 Web 应用程序部署到 Azure 时,此 C# 6 编译器是否可用?

最佳答案

来自String interpolation in a Razor view? :

这仅适用于 MVC6。或者,您还需要从 ASP.Net 添加 roslyn 代码 dom 包。

<div>
@($"Hello {this.Model.SomeProperty}")
</div>

就 Azure 而言,请参阅此链接。 http://azure.microsoft.com/blog/2015/08/11/update-on-net-framework-4-6-and-azure/

With great power… The tooling, framework and Azure platform teams want to ensure the powerful tools we give you to help build your dream is matched by the responsibility we recognize we have to keep it running in the cloud. At the time of the Visual Studio and Azure SDK 2.7 releases, Framework 4.6 wasn’t supported broadly throughout Azure. This is due in large part to the fact that just as many teams (or more) are responsible for the ongoing development and stability of the Azure platform.

For now, we have an update on the availability of .NET Framework 4.6 for Azure App Service and an article demonstrating how to get .NET Framework 4.6 working in your Cloud Service roles.

Azure IaaS For customers using Azure’s Infrastructure as a Service (IaaS) services, installation of .NET Framework 4.6 is manual. To install .NET Framework 4.6 on an Azure IaaS virtual machine, the process is as simple as logging into the virtual machine using Remote Desktop. Once on the machine, the .NET Framework 4.6 installer can be downloaded and installed directly onto the virtual machine. Customers using Azure Automation could also choose to automate the installation onto Azure virtual machines using PowerShell.

Azure App Service Update The Azure App Service team is nearing the end of the testing phase for .NET Framework 4.6 and planning the deployment to the environments. Currently, the plan is to roll out the updates to Azure App Service during August 2015.

Azure Cloud Services Saurabh Bhatia authored an article in the Azure documentation center outlining how to install the .NET Framework in a Cloud Service Role. The content has been recently updated to include commentary specific to .NET Framework 4.6. You can find the updated article here on the Azure documentation center.

关于c# - 在哪里将 Razor 页面语言版本配置为 C# 6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32012051/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com