是否有可能将ASP.NET ASPX解决方案迁移到ASP.NET Core 2.0? [英] Is it at all possible to migrate ASP.NET ASPX solution to ASP.NET Core 2.0?

查看:198
本文介绍了是否有可能将ASP.NET ASPX解决方案迁移到ASP.NET Core 2.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的asp.net(UI ASPX页面WebForms)应用程序迁移到ASP.NET Core2.通过一些搜索,我发现.net core不支持aspx.如果这是真的(有人有确切的文档吗?)有人应该如何将纯asp.net aspx项目转换为asp.net core 2.0?

I want to migrate my asp.net (UI ASPX pages WebForms) application to ASP.NET Core 2. By some search I found out aspx is not supported in .net core. If this is true(anyone has exact documentation for this?) how should anyone proceed to convert from pure asp.net aspx project to asp.net core 2.0?

我使用了便携式分析器工具,但是仅提供每个.dll文件并获取更令人困惑的报告会令人困惑.

I used portable analyzer tool but it is confusing to just give every .dll file and get report which is more confusing.

请尽可能提供有效的Microsoft文档.

Please give valid Microsoft document if possible.

推荐答案

这一切都取决于您所说的迁移".如您对问题的评论中所述,ASP.NET Core不支持Web表单,因此没有任何方法可以将Web Forms网站自动转换为ASP.NET Core网站.

It all depends on what you mean by "migrate". As mentioned in the comments to your question, ASP.NET Core does not support web forms so there isn't any way to just automatically convert an a Web Forms website to an ASP.NET Core website.

也就是说,有可能进行迁移.我一直在为要转换为ASP.NET Core的非常大型的基于Web表单的网站进行此操作.如果您对旅行很认真,那么这里的一些信息可能会对您有所帮助.

That said, it is possible to make the migration. I have been working to do just that for a very large web forms based website that I want to convert to ASP.NET Core. If you are serious about making the journey, then here is some info that will probably help you.

ASP.NET Core的常规体系结构基于MVC,因此它比ASP.NET Web Forms与ASP.NET MVC更相似.因此,您最终将使用MVC模式的某些派生来重写几乎所有的UI代码.您将使用布局而不是母版页.您将使用标签帮助程序来代替服务器控件.您将使用局部和视图组件来代替用户控件.您将使用控制器和视图模型来代替背后的代码.等等.

The general architecture of ASP.NET Core is based on MVC so it's much more similar to ASP.NET MVC than ASP.NET Web Forms. So you will end up rewriting pretty much all of your UI code using some derivative of a MVC pattern. Instead of master pages you will be using layouts. Instead of server controls you will be using tag helpers. Instead of user controls you will be using partials and view components. Instead of code behinds you will be using controllers and view models. Etc.

值得注意的是,仍然存在一个http上下文对象,请求对象和响应对象,它们与Web表单中的类似对象极为相似.这样有助于转换.

It's worth noting that there is still an http context object, request object and response object and they are extremely similar to the analogous objects in web forms. So that helps with the conversion.

另外,为了简化转换过程,您可以构建一个针对整个框架的ASP.NET Core Web应用程序.这意味着,除了System.Web命名空间中的任何内容之外,您将可以访问整个框架中使用的大多数内容.以Full框架为目标确实意味着您的新网站只能在Windows上运行.但是,如果您能够接受(至少现在如此),它将使您的转换过程更加轻松.

Also to make the conversion process easier, you can build an ASP.NET Core web application that targets the full framework. This means that you will have access to most everything you are use to in the full framework except anything in the System.Web namespace. Targeting the Full framework does mean that your new website will only run on windows. But if you can live with that (at least for now) it will make the conversion process easier for you.

如果在您的旧网站中,您将许多功能分解为类库,则将使您的生活更加轻松.您应该能够将这些类库原样带到新网站上,并从ASP.NET Core网站引用它们,并且如果不引用System.Web,它们很可能会正常工作.任何引用System.Web的代码都需要进行修改,以使用新的类似对象或UI方法.

If, in your old website, you broke out a bunch of the functionality into class libraries, that will make your life easier. You should be able to bring those class libraries over to the new website unchanged and reference them from the ASP.NET Core website and they will most likely work fine provided they don't reference System.Web. Any code that does reference System.Web will need to be modified to use the new analogous objects or UI approaches.

因此,最后,您可能无需太多麻烦就可以带来数据模型,数据访问代码,业务对象和业务逻辑.,但是您将必须进行完全重写与UI相关的代码.这就是我要走的旅程,它并不像您想的那么难,至少在您刚开始使用ASP.NET Core时,至少没有.去得到他们!

So in the end, you may be able to bring over your data models, data access code, business objects, and business logic without too much hassle. But you will have to do a total rewrite of your UI related code. That's the journey I'm on and it's not as hard as you might think, at least not once you get up to speed with ASP.NET Core in the first place. Go get `em!

这篇关于是否有可能将ASP.NET ASPX解决方案迁移到ASP.NET Core 2.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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