“ IHostingEnvironment”已过时

编程入门 行业动态 更新时间:2024-10-18 05:56:52
本文介绍了“ IHostingEnvironment”已过时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我将ASP.NET Core项目更新为.NET Core v3.0.0-preview3,现在得到:

I updated my ASP.NET Core project to .NET Core v3.0.0-preview3, and I now get:

启动。 cs(75,50,75,69):警告CS0618:'IHostingEnvironment'已过时:'此类型已过时,将在以后的版本中删除。推荐的替代方法是 Microsoft.AspNetCore.Hosting.IWebHostEnvironment。'

Startup.cs(75,50,75,69): warning CS0618: 'IHostingEnvironment' is obsolete: 'This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.AspNetCore.Hosting.IWebHostEnvironment.'

代码为:

public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { … } }

正确的方法是现在这个吗?是否有任何文档或示例来证明这一点?

What is the correct way to do this now? Are there any documentation or examples to demonstrate that?

推荐答案

似乎 IHostingEnvironment 已由 IHostEnvironment (和其他一些)取代。 您应该能够在代码中更改接口类型,并且一切都会像以前一样工作:-)

It seems IHostingEnvironment has been replaced by IHostEnvironment (and a few others). You should be able to change the interface type in your code and everything will work as it used to :-)

您可以找到有关更改的更多信息在GitHub 上的此链接上 github/aspnet/AspNetCore/issues/ 7749

You can find more information about the changes at this link on GitHub github/aspnet/AspNetCore/issues/7749

EDIT 还有一个附加接口 IWebHostEnvironment 可用于ASP.NET Core应用程序。在 Microsoft.AspNetCore.Hosting 命名空间中可用。

EDIT There is also an additional interface IWebHostEnvironment that can be used in ASP.NET Core applications. This is available in the Microsoft.AspNetCore.Hosting namespace.

更多推荐

“ IHostingEnvironment”已过时

本文发布于:2023-07-17 03:22:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128935.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:IHostingEnvironment

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!