3

I am working on a very large ASP.NET Web Forms project. Our team wants to rewrite this project with ASP.NET MVC and domain driven design. Is it a good idea to combine Web Forms with MVC?

With this idea we can develop every page and use newly developed page in current project. Old pages work with Web Forms and new pages work with MVC and domain driven design until all pages have been rewritten.

1

While it is possible to use the two in the same project, I'd advise against it for the purpose of a rewrite.

Instead, I'd build a facade that handles all the incoming traffic and forwards it to your old implementation or depending on the status of the rewrite, to the new one.

This gives you several benefits, it allows you to work from a fresh project, which means you will be able to structure the way you feel it's best. At the same time you can copy any code you wish to keep. Additionally, if you discover any flaws with your new implementation, you can easily switch back to the old system. If you want to go one step further, you could even call both systems at the same time. The requester would be served with the proven implementation, but internally you keep both and compare the results. Once you are sufficiently satisfied with the new system's response, you make the switch for these types of requests.

  • I like this alternate approach, which seems cleaner and better practice, but feel it lacks some of the practical advantages of being in the same project. Accessing session variables and stuff. – Ewan May 21 '17 at 15:16
  • @Ewan That's a fair objection. Question is, how much state should the website/service be concerned with in the first place? Some of the stateful things can be handled in the facade. But as always though, the answer is it depends" and Mahdi_Nine will have to weight all the pros and cons. – Brunner May 21 '17 at 16:26
  • true, but if you have a webforms app you prob have quite a bit of old style stateful code – Ewan May 21 '17 at 18:34
  • @Ewan Yep. My intention with this answer was to provide an alternative way to solve Mahdi_Nine's problem. It might or might not be more suitable for his current system :) – Brunner May 21 '17 at 19:45
1

I've done this before for a product that we were trying to migrate from Web Forms to MVC and found it worked pretty well. Some notes from my experience:

I used the technique in this blog post to use our existing master page in Razor views. I wanted to avoid having to maintain two layouts, however in hindsight this was a mistake and maintaining two layouts wouldn't have been a better solution. The issue was that Web Forms concepts kept on "leaking" into our MVC pages, for example our master page used a script manager, which caused complications when trying to do thing the "MVC way".

We used a Web-Forms specific UI library, which meant that some UI elements had a slightly inconsistent look and feel.

I seem to recall we had some sort of issue with cookies where the Owin and Web Form APIs didn't interact quite as expected. I'm sorry, I can't remember the details, only that it stumped us for a day or so.

Its worth noting that we never managed to get rid of Web Forms - we just didn't have the time for a complete re-write. I'm not sure this was the best approach, but its also not a decision that I regret.

  • I've also worked on half and half projects and agree it works ok as a migration path. – Ewan May 21 '17 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.