I have a web application that began using WebForms. We've been steadily converting each page to use ASP.NET MVC instead, and we're finally just about done removing all WebForms dependencies entirely.
Are there any dependencies that get baked into a WebForms project, but which can be removed if we're only using MVC pages?
(I've found a post talking about how to remove the WebForms view engine, but I think that's talking about the MVC .ascx-based view renderers, which we haven't entirely eliminated yet.)
How to remove WebForms dependencies from an MVC application
It's simple, 3 steps:
System.Web.UI in your entire solution. If you have more than 0 occurrences found you still have legacy code. Remove them. As a consequence of this removal your project won't probably compile => fix the compile time errors. Fixing the compile time errors doesn't mean anything yet. At runtime you might still hit glitches with some server side controls left in your views.
runat="server" in your entire solution. If you have more than 0 occurrences found in a place other than a content placeholders you still have legacy code.
HttpContext.Current in your entire solution. If you have more than 0 occurrences found you still have legacy code.
But the correct way to port a classic ASP.NET application to ASP.NET MVC is not by doing an in-place replacement. You will most certainly forget stuff. The correct approach is by starting from scratch. By using the Create New ASP.NET MVC 3 application wizard in Visual Studio and progressively migrating the code and views.