Windows上的.NET Core应用程序也可以访问system.web吗? [英] Can a .NET Core app on Windows also access system.web?

查看:1145
本文介绍了Windows上的.NET Core应用程序也可以访问system.web吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个大型的ASP.NET应用程序,我们正在努力朝.NET Core迈进。主要目标是自我托管(再见IIS,您好xcopy部署!)。

We have a large ASP.NET application, that we are working to move toward .NET Core. The main goal is to self host (bye bye IIS, hello xcopy deploy!).

我们有一条将应用程序迁移到Razor(数百个aspx文件)的路径,看起来不错(我们主要使用MVC,所以我们只有一些旧的legacy-asp.net文件要重做至MVC)。

We have a path to migrate the app to Razor (several hundred aspx files), and this looks good (we were mostly on MVC, so we only have a few old legacy-asp.net pieces which we are redoing to MVC).

但是,我们有大量基于.NET 4.6的第三方库。我们被这些库的大多数所困扰。这些库被硬编码到system.web中,以实现许多功能。我们不能更改它。

However, we have a large stack of third party libs that are .NET 4.6 based. We are stuck with most of these libs. These libs are hard coded to system.web for a number of functions. We cannot change this.

所以,问题是:如果我坚持在Windows上运行.NET Core动物,我是否可以同时引用.NET 4.6 / 4.7? ?

So the question: If I stick to running my .NET Core animal on Windows, can I, in process, also reference .NET 4.6/4.7 ?

(不,我们不打算使用微服务,请不要提出这个建议。)

(No, we are not going to microservices, please don't propose that.)

推荐答案

ASP.NET Core是在.NET Core和.NET Framework上运行的一组库。

ASP.NET Core are a set of libraries that run on both .NET Core and .NET Framework.

这意味着您可以创建在.NET Framework上运行并继续使用.NET Framework中所有内容的ASP.NET Core应用程序。这可以通过创建一个新的ASP.NET Core应用程序并编辑 .csproj 文件以从中设置 TargetFramework 来完成。 netcoreapp2.0 net472 并替换 Microsoft.AspNetCore.All 具有单个NuGet软件包的元软件包,这些软件包包含ASP.NET Core库( Microsoft.AspNetCore 等)。

This means you can create an ASP.NET Core application that runs on .NET Framework and keep using all the stuff that is in .NET Framework. This can be done by creating a new ASP.NET Core application and editing the .csproj file to set TargetFramework from e.g. netcoreapp2.0 to net472 and replacing the Microsoft.AspNetCore.All metapackage with individual NuGet packages containing the ASP.NET Core libraries (Microsoft.AspNetCore etc.).

尽管这也使您可以使用System.Web中的类型,但是由于ASP.NET Core应用程序未在IIS中运行,因此这可能没有用。不能使用System.Web的HttpContext(因为没有IIS / ASP.NET HTTP上下文)。

While this also gives you access to using types in System.Web, this may not be useful since the ASP.NET Core application does not run in IIS, so e.g. HttpContext from System.Web cannot be used (since there is no IIS/ASP.NET HTTP context).

因此,最重要的是,这取决于System.Web的功能您正在使用的库取决于。

So bottom line, it depends on what functionality of System.Web the libraries you are using depend on.

这篇关于Windows上的.NET Core应用程序也可以访问system.web吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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