Integrating / migrating to MVC3 from WebForms with a large existing library of custom controls

Here is the situation. We are adding a new application to our Webapps-based webapps package, and so I felt that this would be the perfect time to implement MVC.

I did all the research on mixing the two and got a project set up using Area that uses MVC routes, while the rest of the project (visual studio) works with web forms the way it was run.

The back pages were converted to Razor layouts, not so bad because there was only one main page that was shared between each application.

The problem I am facing is the reuse of user controls. We have dozens of custom user controls, many of which are quite complex, which are reused in all of our applications. Most of them (especially those that are difficult to carry) make a fair amount with ViewState and postbacks.

If it were just a rewrite of this data in MVC, a one-time cost would be less ideal, but not terrible. But since existing applications need to be maintained and updated, it seems that keeping two versions of the same behavior using completely different paradigms would be a huge performance drain.

My gut says that there really is no good solution, and we may have to give up the idea of ​​moving to MVC for this project and sticking to web forms, but I wanted to see if the SO community has any idea what to do in this scenario.

+4
source share
1 answer

If you have a budget to rewrite these server-side controls using the MVC paradigm, which would be the best way. If not, you can put them in existing classic WebForms pages and which will interact with the new MVC application using standard HTTP / HTML methods: compose messages, send identifiers via query string parameters, iframes, cookie, HTML 5 storage, etc. One thing is certain: try to avoid placing these server-side controls in your MVC views. As a result, you get some kind of hybrid application that is not proper ASP.NET MVC and will not be correct WebForms, which would be a disaster.

Personally, I had to perform the same migration several times, and I did not mix classic WebForms with MVC in one application using scopes or some other methods. In the end, it can turn into a nightmare, trying to make these two creatures together. It is always one of two things: I have a budget, and I rewrite correctly from scratch or I don’t have a budget, and I am correctly doing new material using ASP.NET MVC and trying to interact with an existing application.

It’s easier for me to simply launch a separate MVC application, which, depending on the interaction I'm looking for, will use different methods to integrate functionality from an existing WebForms application.

I don’t really understand the complexity and details of your script, so it’s difficult to give an objective answer, but the ability to continue to write new code based on existing controls on the WebForms server side and not to do any MVC for this project at all can be a good solution. Writing a new application in ASP.NET MVC just for the sake of this may not always be the best choice.

+4
source

All Articles