且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 ASP.NET WebForms 迁移到 MVC

更新时间:2021-08-17 00:48:28

我有一个非常大的旧 ASP.NET WebForms 应用程序(它最初是为 .NET 1.1 编写的!)并且已经启用 MVC 在其中工作,侧面- 并排.我一直在使用 MVC 编写新功能,并将旧的 WebForms 功能转换为 MVC 控制器和视图.

I have a very large and old ASP.NET WebForms application (which was originally written for .NET 1.1!) and have enabled MVC to work in it, side-by-side. I've been writing new features using MVC, and converting old WebForms features to MVC controllers and views.

我遇到了一些关于 URL 授权和在 IIS 集成模式下运行的小问题,但是一旦我了解了这些问题,它们就很容易解决了.几乎不可能?当然不是!

I ran into a few little issues concerning URL authorization and running in IIS integrated mode, but once I understood the issues they were fairly easy to work out. So nearly impossible? Certainly not!

我无法告诉您转换它是否值得,因为我不知道您的应用程序的大小、范围或性质,或者任何业务限制.然而,迁移到 MVC 对简化开发和质量来说是一个相当大的好处(因为它更容易划分和单元测试).更不用说,我在 MVC 中编写(或重写)的功能比 WebForms 等价物更干净、更快、响应更快.

I can't tell you if it's worth your time to convert it, since I don't know the size, scope or nature of your application, or any business constraints. However, moving to MVC has been a considerable boon to ease of development and quality (since it is easier to compartmentalize and unit test). Not to mention, the features I've written (or rewritten) in MVC are much cleaner, faster, and responsive than the WebForms equivalents.

我很高兴将它从 MVC v2 移动到 v3,并转换为 Razor 视图.我也会?如果我是你并且有时间,我会去做.

I'm excited to move it from MVC v2 to v3, and convert to Razor views. So would I? I if I were you and I had the time, I'd do it.

这是我发布的一个问题,概述了该过程以及我在转换中遇到的一个更重要的问题.将旧版 ASP.NET 迁移到MVC 2 (RC):HttpApplication 事件未触发,用户主体为空

Here's a question I posted that outlines the process and one of the more significant problems I had in the conversion. Migrating legacy ASP.NET to MVC 2 (RC): HttpApplication events not firing, User principal is null