Does anybody have experience in maintaining Sitecore MVC and Web Forms in a single solution? [closed]

谁都会走 提交于 2019-12-12 02:22:30

问题


We have a multi site project in Sitecore 6.5 Web Forms which requires decent refactoring, architecture redesign and we want to upgrade it to sitecore 8. Of course it will be easier to start something brand new, but the project is huge and probably it won't be possible to rewrite it to MVC in completely new solution because of time that will be required to have all sites up and running. That's why we started to think if it is possible to keep the old solution and add there MVC project which allows us to write new sites in MVC and slowly refactor the legacy code in the meantime.

I saw John West's post about using Web Forms and MVC in a single solution http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2012/06/using-web-forms-and-mvc-in-a-single-solution-with-the-sitecore-aspnet-cms.aspx but I need to be certain that it will not cause any problems in the long run, before we propose this solution to the customer.

Does anyone have experience with keeping both type of projects in a production application? Is it possible to do a migration sublayout by sublayout without any risk? Can we have in one time part of the site in web forms and part in MVC (of course with pages separation to only Web Forms or only MVC controls)? Do you know about any constraints that we should be aware of?


回答1:


It is indeed possible for Sitecore WebForms and MVC to co-exist within the same solution. It seems like you have two goals here though which should be treated separately. 1) the updgrade to Sitecore 8 from 6.5 which is not a small task and 2) conversion from WebForms to MVC.

Assuming a re-write is out of the question, I would start first with getting the solution upgraded to Sitecore 8 (or even better to 8.1). If your existing solution uses the DMS, then this will be a significant job in addition to the rest of the upgrade.

After you have a working WebForms solution upgraded to Sitecore 8 / 8.1 you could then think about changing parts of the solution to MVC. WebForms and MVC can happily co-exist within a project, the only limitation is that each page should be either 100% WebForms or 100% MVC. Creating an MVC version of the Layout would be the first task, followed by your components. It is possible that during your conversion process you could have duplicate markup but that should not be a major issue. If you are new to Sitecore MVC you will want to learn about the different rendering types available and know which to choose for what purpose (here is an introduction to Sitecore MVC presentation concepts and notes about moving to Sitecore MVC). If there are any forms in your solution, I would upgrade them last as they might require the biggest change when moving to MVC.




回答2:


No problem to have MVC and Web Forms together in a Sitecore 8. but out of the box there is no support to mix MVC and Web Forms placeholder. So a page is MVC with MVC sublayout. or Web Forms with WebForms sublayouts.

There are solution to do mix that. But it is not advisable see https://github.com/HedgehogDevelopment/sitecore-mvc-aspx-interop

Web Forms on a MVC page: http://www.chrisvandesteeg.nl/2014/02/11/usercontrol-renderings-in-a-sitecore-mvc-website-wffm-for-mvc/

A while back we had this subject on a SUGNL meetup you can read the summary on: http://sitecore.robhabraken.nl/index.php/2288/sugnl-colours-2015/

Or read this http://www.nonlinearcreations.com/Digital/how-we-think/articles/2015/05/MVC-Web-Forms-Hybrid-Sitecore.aspx



来源:https://stackoverflow.com/questions/34016910/does-anybody-have-experience-in-maintaining-sitecore-mvc-and-web-forms-in-a-sing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!