转换web表单项目混合MVC4项目 [英] Convert a webforms project to a hybrid MVC4 project

查看:164
本文介绍了转换web表单项目混合MVC4项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们有大约800 .aspx页旧式ASP.NET项目。

我们正在寻找在一段时间内从ASP.NET web表单迁移这MVC4 +剃须刀,但不希望有放弃整个项目重新开始。

是否有可能在项目文件转换为MVC项目并添加所需的文件/文件夹的项目作为一个MVC项目中运行,但在同一时间,preserving原来的文件/文件夹结构允许仍然在像现在访问相同的方式进行访问现有/遗留页


解决方案

  

是否有可能在项目文件转换为MVC项目并添加
  该项目作为一个MVC项目运行所需的文件/文件夹


根据我与VS2012 Web应用程序项目具有几百年的.aspx的经验,这绝对是可能有WebForms和MVC 4剃刀在同一个应用程序中运行。

我们没有修改项目文件(稍后更多)。我们从裸MVC4启动应用程序,并在我们的web表单应用程序复制所需要的功能。这包括:


  • 包和引用

  • 在web.config中的指令(只要我还记得:无扩展名的处理程序,system.web.webPages.razor元素和一些装配绑定)

  • 大多数在Global.asax机制(即路由的裸应用程序)

  • 目录结构(模型,视图和控制器)

这是一项繁琐的工作,但它也帮助我们了解是什么让一个MVC项目工作。我们仍然怀念例如没有MVC组件(视图,控制器)提供时右击一些IDE功能 - >添加...我想这将需要的csproj编辑。我们没有走那么远。

要prevent冲突的网址,MVC是通过多个专用领域使用将,到了最后,替换相应的web表单文件夹中。

At the moment, we have an old style ASP.NET project that has around 800 .aspx pages.

We are looking at migrating this from ASP.NET webforms to MVC4 + Razor over time, but do not want to have to scrap the entire project and start again.

Is it possible to convert the project file to an MVC project and add the required files/folders for the project to run as an MVC project, but at the same time, preserving the original file/folder structure allowing the existing/legacy pages to still be accessed in the same way as they are now accessed.

解决方案

Is it possible to convert the project file to an MVC project and add the required files/folders for the project to run as an MVC project

Based on my experience with a Web Application project on VS2012 featuring several hundred .aspx, it is definitely possible to have webforms and mvc 4 with razor running in the same application.

We did not modify the project file (more on that later). We started from a bare MVC4 application and copied the needed features in our webforms application. This included :

  • packages and references
  • directives in the web.config (as far as I remember : extensionless handlers, system.web.webPages.razor element, and some assembly bindings )
  • most of the global.asax mechanisms ( namely routing for a bare application)
  • directory structure (models, views and controllers)

This was a tedious work, but it also helped us understand what makes an MVC project work. We still miss some IDE features like not having MVC components (views, controllers) offered when right-click -> Add... I guess this would require a csproj editing. We did not go that far.

To prevent conflicting urls, MVC is used through several dedicated areas which would, in the end, replace the corresponding webforms folders.

这篇关于转换web表单项目混合MVC4项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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