Rebuilding Web Forms Applications in MVC

The transition between Web Forms and MVC can be easy. In this course, you'll explore how to rebuild legacy ASP.NET Web Forms applications in MVC. You'll look at how development translates between frameworks by rebuilding a sample application.
Course info
Rating
(184)
Level
Intermediate
Updated
Apr 12, 2016
Duration
3h 49m
Table of contents
Course Overview
Putting Web Forms and MVC in Perspective
Request Management
Designing with Layouts and Views
Working with Forms
Implementing Data Validation
Understanding Partial Views and Child Actions
Enhancing the Application with Ajax
Working with Data
Description
Course info
Rating
(184)
Level
Intermediate
Updated
Apr 12, 2016
Duration
3h 49m
Description

Transitioning from ASP.NET Web Forms applications to MVC applications can be difficult, but you can ease the transition. This course, Rebuilding Web Forms Applications in MVC, will help developers, like you, to migrate to a new framework. You'll complete this task using a two-tiered approach: first, you'll compare and contrast what high-level concepts are shared between Web Forms and MVC. Next, you'll learn how they are both built on the larger ASP.NET platform. Finally, you'll explore how the specific implementation details of those concepts vary between frameworks, demonstrated by rebuilding a meaningful sample application. By the end of this course, you'll be more prepared to rebuild apps and make a smooth transition to MVC.

About the author
About the author

Alex Wolf is passionate about software development and mastering new technologies. He has several years of experience working almost exclusively with the .NET Framework and related platforms. Alex is also a Microsoft Certified Professional in both MVC Application development and HTML 5 technologies. He loves learning new things!

More from the author
Android: Image Processing with Picasso
Beginner
1h 57m
9 Mar 2018
Android: Getting Started with Retrofit
Beginner
2h 20m
10 Jan 2018
More courses by Alex Wolf
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi, everyone. My name is Alex Wolf, and welcome to my course on Rebuilding Web Forms Applications in MVC. ASP. NET Web Forms is an established and well documented platform, but as it continues to age, many companies and developers continue to move to newer technologies. The MVC framework has emerged as a great alternative, due to its strong support for modern design patterns. Rebuilding a web application in any framework requires understanding how that technology implements core web development concepts. So, I'll be sure to cover important topics, like how HTTP Requests are routed and handled by these two frameworks. We will also learn how to work with forms and secure them with meaningful validation rules. Our application will also provide great features, like strong support for Ajax. Along the way, we'll also discuss how to properly architect our application and structure it using manageable components. By the end of this course, you'll understand how to rebuild existing Web Forms projects in MVC and just feel comfortable starting new applications on a modern framework. If you're already familiar with MVC, you can also use this course to improve your understanding of legacy Web Forms applications. Before starting this course, you should be somewhat familiar with the ASP. NET platform and general web development concepts. Some knowledge of either web forms or MVC is also very helpful, depending on which framework you're trying to learn more of from this course. I'm really excited to move forward on this project, so let's get started right here on Pluralsight.

Putting Web Forms and MVC in Perspective
Hi I'm Alex Wolf, and welcome to this course on rebuilding web forms applications in MVC. I'm really excited about this topic because it's one of the more common DEV scenarios that I've seen in the last few years. Companies are continually looking to improve their applications. Often they want to migrate to a newer technology at the same time for added value. Rebuilding and improving an application in parallel can be a daunting challenge and that's why this course exists. Our main goal is to smooth that transition from one framework to another. We'll approach this task using a two tiered approach. First we'll examine what high level concepts remain the same between web forms and MVC. Remember both frameworks sit on top of the same ASP. NET platform so they do share some common infrastructure. Secondly, I'll demonstrate how the more specific implementation details of these concepts do vary between the two frameworks. This will involved working through some demos with a sample application that I've put together. Now I like to keep introductions as short as humanly possible, but before we move ahead, let's quickly review the content of this course and whether it's a good match for where you are as a developer.

Request Management
In this Module, we want to begin rebuilding our Web Forms Application. To do this, we need to cover a few topics related to the overall architecture of ASP. NET, Web Forms and MVC. We need to understand how Http Requests are processed by the two frameworks since this is really the heart of any Web Application. Let's quickly step through our agenda for this Module so that we can get started. First, I'll explain and demonstrate how MVC and Web Forms are built on the larger ASP. NET platform and really what this means from an architectural prospective. We'll then review how Requests are handled in each framework starting with Web Forms and its really unique Page Life Cycle. I'll be sure to demonstrate these concepts using the Web Forms version our sample Application. We'll also use this opportunity to walk through the general structure that project in the code. So you'll understand exactly what we're going to be rebuilding. Next, we'll move on to an overview of the MVC processing pipeline and we'll see just how it differs from Web Forms. Now a crucial concept for understanding Request Management in MVC is Routing. So I've included a lesson and a demo just for that topic. Finally, we'll begin to build out the structure of our new MVC application using Controllers and Action Methods. So let's get started on all this in the next lesson.

Designing with Layouts and Views
In this module, we want to focus on implementing the styles, layout, and general branding of our application. MVC and WebForms share a high-level concepts in terms of building the visual design of web pages. But the actual implementation details are very different. The topics in this module are fairly straightforward and our application will really start to take shape so the upcoming lessons should be very rewarding. We'll start off by revisiting our web forms application to see how the graphic design of our app was originally implemented. Once we understand what we're trying to rebuild, we'll discuss just how to do that using MVC views and layouts. This will include a demo where we walk through reconstructing the various web pages and pulling in some style resources. Next, we'll look at how various HTML components were constructed in our legacy project, such as the forms that users fill out. I'll then provide an introduction to the Razor View Engine and its HTML helpers which will help us accomplish these types of tasks in MVC. Let's get started in all this in the next lesson.

Working with Forms
Starting with this module, we want to begin building some of the more dynamic and interactive sections of our application. So in the next few lessons, let's explore how to work with forms and submitted data in MVC. First, we'll begin by reviewing how our legacy Web Forms application handles HTML form submissions. We can then move on to discuss how this process works in MVC. This will require a strong understanding of model binding, which is a really powerful feature of the MVC framework. We'll then step through our applications data layer to get a better idea of the structure that we'll be working with. We also want to finish rebuilding the actual HTML of our form using Razor, which will help make our markup more dynamic and more friendly for model binding. Finally, we'll step through the logic of how to process the incoming data from our form and persist it to a database. Our application will start to become much more than just static markup in this module, so let's move ahead and get started on all this.

Implementing Data Validation
At this point, we've successfully created one of the forms in our application, but it could certainly use some improvements. In this module, let's enhance the experience for both the user and the developers by implementing data validation. We'll start by revisiting our legacy web forms app to see how form validation was originally implemented. This will also help us understand what types of validation rules we have to re-create. We'll then discuss how validation is implemented in MVC through data attributes, and apply those concepts to our task form. Our application also has a few more specific validation requirements that the default MVC components can't quite handle, so we'll look at how to implement custom validation rules as well. There are two primary ways to accomplish this by either using data attributes or by implementing a special interface, and I'll demonstrate both of those techniques. Let's get started on all this in the next lesson.

Understanding Partial Views and Child Actions
In this module, let's discuss child actions in MVC and how to extract parts of our application into more manageable components. To do this, we'll be dissecting the widgets on the homepage and rebuilding them using MVC tools and techniques. So as usual, we'll start by examining how these widgets were originally implemented in Web Forms through user controls. This will also be a good opportunity for us to make sure we fully understand the functionality and requirements of both widgets. We can then move on to properly discussing child actions in MVC, which I've alluded to previously but we've not yet covered in detail. Once we understand these concepts, we can step through extracting both widgets into a child actions. These two items have different technical requirements, so I'll demonstrate how to re-create the functionality of each of them using MVC design patterns. Let's move ahead with this discussion in the next lesson.

Enhancing the Application with Ajax
In this module, we want to improve the user experience and functionality of our application using Ajax. MVC provides powerful support in various techniques for working with Ajax, so we'll explore a few of them in the upcoming lessons. This should be a rewarding module, since we'll achieve considerable improvements to our application with a very reasonable amount of development effort. We'll start by discussing how MVC handles Ajax requests conceptually as well as some of the tools it provides to streamline this process. This will include utilizing additional Razor helpers and putting them to use in a demo that will enhance one of our widgets. We will also see how we can handle Ajax requests from straight JavaScript that we write without the aid of the MVC helpers. Much like other features of MVC, Razor helpers can streamline your Ajax work flows, but aren't necessarily a requirement. Finally, we'll also see how we can really leverage Ajax calls, not just for updating parts of our views, but also for working with form data and really improving that user experience as well. I'm excited about the feature improvements we'll see in this module, so let's get started on them in the next lesson.

Working with Data
So we've reached the last but certainly not least module of this course. Up until now, we've focused on specific features of our application, but now we want to really bring things together by removing all of the remaining static content. This will involve managing and displaying data using different techniques and tools. We'll begin by revisiting our legacy app and examining how it handles displaying lists of data or pages that contain different types of data. We'll then use those concepts to compare and contrast how MVC handles the same type of tasks. Through a series of demos, we'll step through these techniques and remove all the static data in our application. So first, we'll rebuild the data widgets on our homepage that display recent tasks and messages. Next, we'll move on to the main listing pages for each of those datatypes, and see how we can make those dynamic as well. We also have one simple but important page left to build, which is the reply form where admins can maintain a conversation with users. Throughout these demos, we'll earn a couple of techniques that can also enhance the model binding features of MVC, so we'll revisit some of the functionality we added earlier. Finally, we'll briefly explore how to add dependency injection to our application and discuss other next steps for making improvements to the overall design of our app. So going off that last point, the focus of this course is still the fundamentals of how to rebuild a web forms app in MVC. But I do want to point you toward potential next steps in your journey. Once you have a properly structured MVC app, you can begin to leverage all kinds of great features, like unit testing, loosely coupled components and other layers like services and repositories. I'm excited to fully bring our application to life in this module, so let's get started in the next lesson.