Compatibility of ASP.NET Webforms and ASP.NET MVC
As the pool of technology supporting Webforms continues to shrink, you want to know if it’s a good idea to modernize your application by integrating ASP.NET Webforms and ASP.NET MVC. Judging from our vast experience with clients making the same move, it is worth it.
Done right, you can avoid the high cost of maintaining legacy systems. That’s better performance on crucial business tasks, and better profitability.
This article explains the compatibility of ASP.NET Webforms and MVC, how developers combine them, as well as the risks and rewards.
Explaining ASP.NET Webforms and ASP.NET MVC
Although ASP.NET Webforms is still available in Visual Studio, the framework is no longer the most innovative. As most interactive designs are centred around JavaScript, Webforms isn’t suitable for all applications e.g. in the cloud. This is because the load speed is too slow for modern expectations.
JavaScript does work well with server control HTML generation which is not the outdated Webform’s strong suit. But it’s a breeze for ASP.NET MVC architecture. ASP.NET MVC is Microsoft’s more robust upgrade to the legacy ASP.NET Webforms that solves Webforms’ JavaScript development issues. It does not use view state or server-based forms making it easier for developers to work faster and more securely.
However, it is not necessary to completely rewrite your legacy system. It is possible to leverage ASP.NET MVC for your existing ASP.NET Webforms apps as you modernize your legacy application. It is one of the reliable legacy system modernization approaches we have helped clients with. It’s a solution that addresses the critical failures, security problems, process efficiency, and costs of running Webforms.

ASP.NET MVC is bound to the same runtime environment as ASP.NET and has tight dependencies on IIS and the system.web assembly. As ASP.NET MVC requests are routed through the same exact pipeline, the two are compatible. In fact, intrinsic objects such as Cache, Session, and User are the same, and plain ASPX pages work without any changes to the configuration as the system can match MVC and Webforms.
Using Mixing ASP.NET Webforms and ASP.NET MVC in One Application
Let’s look into the viability of this approach to answer your questions on legacy application modernization. If your aim is to add new features using Ajax and libraries such as jQuery, jQuery UI, Bootstrap, Knockout.JS, or Breeze, consider merging the MVC project with Webforms. Leveraging them together in your legacy software allows you to take advantage of ASP.NET MVC’s support for HTML rendering and more.
You also have to be aware of common add Webforms to MVC project problems in legacy system integration. The major disadvantage of mixing Webforms and MVC has two separate areas within the runtime might slow down performance as debugging is done for both sets of requests. However, the difference is negligible given that the extra load is limited to system.web.mvc. Partnering with a software modernization company will help you negotiate this modernization approach successfully.
When Can I Mix ASP.NET Webforms and ASP.NET MVC?
So when does mixing MVC and Webforms in one project work? Here are different scenarios most of our clients encounter.
Case 1 Complete move to ASP.NET MVC
If you are planning completely migrate WebForms to MVC, it might turn into a hybrid Webforms MVC app during the move. Gradually all modules will be rewritten for MVC, but in the meantime, you can mix the two so as to keep your application running.

Case 2 Adding new features in JavaScript
Thinking of adding new JavaScript-intensive features in MVC without touching the rest of your code? Then mixing Webforms and MVC is a viable option. You can simply add new features using MVC concepts without having to rewrite the whole application.
When not to Mix ASP.NET Webforms and ASP.NET MVC
Modifying your application to take advantage of popular JavaScript programming doesn’t always have to mean rewriting your code. Neither does it mean you have to mix Webforms and MVC. Modernizing your existing Webforms project to be more interactive and rich typically involves leveraging jQuery and jQuery UI plugins. You can achieve this by adding a Web API to your Webforms application. After all, there is nothing wrong with using Webforms for your applications.
Using alternative solutions
If you decide not to go with this hybrid approach, you can choose to:
Rewrite using ASP.NET MVC
If you are compelled to ditch Webforms completely for ASP.NET MVC, it’s going to be time intensive. As you are dealing with an existing project, it is realistic to assume you will be rewriting everything one module at a time.
The process itself involves writing controllers, Razor views, and routes as well as preparing CSS and script bundles. In addition to familiarising your team with elements like the Twitter Bootstrap framework and libraries such as jQuery and Knockout, you will also need AngularJS expertise.
Insert Web API
Opting to integrate a Web API layer into a Webforms application is less strenuous compared to rewriting your entire project. Web API is somehow similar to ASP.NET MVC in how it works. It makes HTTP endpoints easily callable to JavaScript frameworks. However, unlike MVC, it is completely separated from the ASP.NET runtime.

Explaining how to insert APIs to consolidate your legacy systems under one roof. How to Effectively Conduct a Legacy System Integration
The Web API solution doesn’t require much work to produce more interactive applications. You simply plug in the Web API runtime, configure routing choose the URLs you want to support, and start writing your controller classes in the App_Code folder. Here is a sample:
public class NewsController : ApiController
[HttpGet]
public IEnumerable<string> All()
{
// Your logic and return data
}
How to Blend MVC Modules and ASP.NET Webforms
To utilize Webforms and MVC in the same project, you can add MVC references to the existing application. But how?
You should know that the ASP.NET MVC framework was developed on top of ASP.NET. Thus, technically, the only difference is that while ASP.NET is found only in System.Web; ASP.NET MVC lives in System.Web,System.Web.Routing, System.Web.Abstractions, and System.Web.Mvc. When you add these assemblies as a reference in an ASP.NET application, you have a perfect footing for merging the two technologies.
Put simply, since ASP.NET MVC is built on top of ASP.NET, data can be easily shared between the two technologies. For example, data can be transferred through the Session state because of the availability of the Session state object in both technologies.
The two frameworks ASP.NET Web Forms and ASP.NET MVC can easily share data as they also share the same runtime environment. Requests are routed through the same pipeline. All that is needed for the incoming request is to match the URL specifications supported by the MVC handler.
Put more simply
Follow the following steps. Add a reference to the three assemblies to your ASP.NET application:
- System.Web.Routing
- System.Web.Abstractions
- System.Web.Mvc
Subsequently, create the ASP.NET MVC folder. Since this framework relies on some conventions (e.g. controllers living in Controllers), adhere to the conventions. Add all the necessary folders, Controllers, Views, and Views | Shared to your existing ASP.NET application.
After that, you have to update the web.config file using a code that registers a default ASP.NET MVC route, which will map any URL of the form /Controller/Action/Id into a controller instance and action method to avoid MVC Webforms hybrid problems.
Complete the process by introducing a new controller in the Controllers folder to add Webforms to the MVC project. You can also add Webforms to MVC projects as they are compatible both ways.
Consider ModLogix as Your Legacy System Migration Partner
Of course, evaluating which method to use is best done in a case-by-case scenario. With ModLogix as your legacy system migration partner, you can be sure you are doing the legacy system upgrade right.
Moving a WinForms App to .NET Core 3.2
Our team upgraded a clunky desktop app to a modern web-based solution.
VIEW CASE STUDYOur team of experts helps you evaluate your Webforms project, the changes you need done, and how best to do them. We have worked with hundreds of clients introducing MVC in Webforms projects and know how to smoothen the transition for you. We specialize in providing custom solutions for migrations.
Final Thoughts
Modernizing your existing Webforms project to be more interactive would typically mean rewriting the legacy platform or adding a Web API. However, combining ASP.NET Webforms with MVC is also an option. Done right, it can deliver the changes you want while avoiding common MVC and Webforms hybrid application disadvantages like slower load speed.