从ASP.NET的WebForms迁移到MVC [英] Migrating from ASP.NET WebForms to MVC

查看:177
本文介绍了从ASP.NET的WebForms迁移到MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过大量的问题和文章指出,从ASP.NET Web表单转换为MVC是足够的几乎是不可能的。但是我觉得我的情况是不同的。

I've read plenty of questions and articles stating that converting from ASP.NET Webforms to MVC is near enough impossible. However I think my scenario is different.

我傻傻开始在Web表单开工的项目大约一年前,但我采取的方法(据我所知)非常喜欢MVC。我有残疾的形式验证,不使用任何回发,使用URL重写,所有页面的变化是加载ContentPlaceHolders的页面内容(使用小黑客,重写AJAX请求 RenderControl 方法)。我还用我自己的ORM和RESTful服务API在单独的项目,在网站上引用的。

I foolishly started working a project about a year ago in Webforms, but the approach I took (as far as I understand) is very MVC like. I have disabled forms validation, don't use any postbacks, use URL re-writing and all page changes are AJAX requests that load the page contents of ContentPlaceHolders (using a small hack, overriding the RenderControl method). I've also used my own ORM and RESTful Service API in seperate projects, referenced in the website.

现在的系统确实很好,在页面部分刷新细而当Ajax调用作出的改变的URL,所以页面被刷新时,它看起来完全一样的。

Now the system works really well, the pages are partially refreshed fine and the url's are changed when the ajax calls are made, so when the page is refreshed, it looks exactly the same.

现在我刚刚被告知我需要学习MVC一个新的大项目(但我必须先完成其他项目中),但我已经做了一些阅读关于这个问题,并开始了一些的Hello World应用程序,它似乎是ASP.NET MVC的想法是pretty很多正是我已经创建。

Now I've just been told I need to learn MVC for a new big project (but I have to finish another project first), but I've done a bit of reading on the subject and started a few Hello World apps, and it seems that the idea of ASP.NET MVC is pretty much exactly what I have already created.

计算器会仍然建议对Web表单应用程序转换为MVC?有没有转换为MVC,除了最佳实践的任何其他好处?

Would StackOverflow still recommend against converting the Webforms application to MVC? Are there any other benefits of converting to MVC, besides best practices?

推荐答案

我有一个非常大的老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,并转换为剃刀意见。我也会?我如果我是你,我有时间,我会做到这一点。

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.

下面是我张贴,概述的过程和我在转换中更显著的问题之一的问题。 <一href=\"http://stackoverflow.com/questions/1979066/migrating-legacy-asp-net-to-mvc-2-rc-httpapplication-events-not-firing-user\">Migrating传统的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

这篇关于从ASP.NET的WebForms迁移到MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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