If you are in the process of upgrading or migrating to ASP.NET MVC from ASP.NET Web Forms, here are some things you should know before beginning your migration:
- ASP.NET MVC no longer has DataSource controls that you can use for performing Data Binding. Instead, you have to perform Model Binding. Models are usually classes and can either be populated through your Controller or can be bound directly to Entity Framework classes. The use of ADO.NET in ASP.NET MVC projects has been largely replaced by the use of Entity Framework and LINQ.
- ASP.NET MVC no longer has the concept of a code-behind and server side events. Instead, all operations are performed in your Controller and the only 2 major events you have to handle are [HttpGet] and [HttpPost]. All other events need to be handled client side.
- ASP.NET MVC no longer has any server side Web Controls whatsoever. Instead, you have to work with Html Helpers. These code snippets simply help you generate the standard HTML you would normally generate using the ASP.NET Web Server controls. Of course, as you can guess from the previous bullet points, no server events are exposed with these Html Helpers.
- If you want to perform Validation, you have to leverage validation capabilities available through Data Annotations in Model Binding as well as client-side validation performed using the jQuery Validation Library.
- Most of the rich set of controls that were previously available in ASP.NET Web Forms either directly through Microsoft or through 3rd party control vendors have been largely replaced by jQuery, jQuery Plugins and jQuery UI. If you cannot find what you need amongst those libraries, you may have to hunt around on the Internet or for other 3rd party vendor controls such as Telerik Kendo UI, Infragistics IgniteUI, ComponentOne Wijmo or various others. Of course, many of these libraries are still missing functionality found in some of the ASP.NET Web Server controls such as the FormView control and the Wizard control.
- Whereas most 3rd party controls in ASP.NET Web Forms used built-in styles and skins through bundling of resources directly into the .NET assemblies, 3rd party controls now heavily rely on the use of external stylesheets to be included as part of the Views in order for the controls to render properly.
- While you can still use .aspx pages in ASP.NET MVC Views, the general standard for ASP.NET MVC Views is now .cshtml with the Razor syntax. Though it is possible to mix-and-match .aspx views with .cshtml views, it is very tricky and generally not recommended.
- ASP.NET MVC Views do not provide a Design view (and consequently no drag and drop features). Therefore, all of your UI development has to be performed in Source code view.
- While you can easily create an ASP.NET Hybrid application (ASP.NET Web Forms and ASP.NET MVC) in Visual Studio 2013 using ASP.NET 4.5, configuring your projects to do this in Visual Studio 2010 and Visual Studio 2012 is still largely a manual process.