“ IHostingEnvironment”已过时 [英] 'IHostingEnvironment' is obsolete
问题描述
我将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
上的此链接上 https://github.com/aspnet/AspNetCore/issues/ 7749
You can find more information about the changes at this link on GitHub https://github.com/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”已过时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!