In this first season David Findley will demonstrate how to build Twitter’s web-based interface using ASP.NET MVC with help from LINQ to SQL, jQuery, Ajax and SQL Server. You’ll watch every step of the process from concept to delivery of this exciting new series, built using both C# and Visual Basic.
Videos in this series:
In this first episode David introduces us to the Twitter user interface and briefly scopes out what we’ll be building using ASP.NET MVC.
In this episode Dave sets up his development environment with the help of the new Web Platform Installer from Microsoft, detailing the options you’ll need to select in order to follow along. He also creates the new ASP.NET MVC project and briefly walks through the file structure of the new project.
In this episode Dave gets to work starting with a gentle introduction to how page requests are handled using ASP.NET MVC’s routing feature (adding MapRoutes in the Global.asax), and adds a new View and Controller method for the new Member home page. Finally, he restricts access to the Member home page to only those who are authorized on the web site using the Authorize attribute. He also discusses the RedirectToAction helper method in detail.
In this episode Dave demonstrates how to add the ability to post status messages to the application and explains form post handling in ASP.NET MVC including best practices. He uses the Html class, AcceptVerbs.Get and AcceptVerbs.Post attributes, explains the Post-Redirect-Get pattern, and the RedirectToAction() helper method to implement this functionality.
In this episode Dave adds a table to the ASPNETDB.mdf database to allow for posts that were collected from the previous video and demonstrate how to use the LINQ to SQL designer to create a data access layer, a Model — the M part of MVC — as well as the Controller to save the status updates for the application. He also demonstrate how to extend the LINQ to SQL Model (using a partial class) to create a helper method that can be used throughout the entire application.
In this episode Dave creates the timeline view of user generated Twix posts by creating a strongly typed view, enabling eager loading in LINQ to SQL using DataLoadOption.LoadWith(), and styles the HTML using CSS. He also demonstrates ho to enable compile time checking for strongly typed view and much more.
In Episode 7 Dave enables the Profile page by utilizing ASP.NET MVC’s Partial Views, demonstrates the Html.ActionLink() method, and beautifies the URL to the Profile by parameterizing the route with the UserName. He also performs a little CSS cleanup, and much more.
Continuing on, Dave focuses on “followers” … refactoring to add follower mapping in the database and the data context. This includes time spent setting properties of the association between the new entities to create a parent / child relationship between follower and follow-ee. He then focuses on creating helper methods to follow and stop following other Twix users and other methods that will assist when rendering the Views. During this time Dave explains the RedirectToAction method and shows how to use the ‘Using’ keyword to begin / end an HTML form. He also points out a few best practices: ex. Why you would want to use form posts instead of querystrings when dealing with action methods that are making changes to the database. He then discusses different approaches to sending information from the form to the action methods (hidden form fields, an Html.BeginForm method overload to send routeValues, etc.) By the end of the video, Twix users are able to follow each others posts.
In this episode Dave turns his attention to implementing the Account Information page which leads to discussions about form construction, form handling, handling form validation messages between the controller and the view, working with lists of data in a combo boxes, and explains the true value of the Html helper methods, like TextBox (loads current value of the textbox from the model, etc.)
In this episode Dave adds functionality to allow the user to upload a picture to use on their profile that would be displayed in the timeline. He demonstrates using InputStream to save the image from the HTML form and how to manage the uploaded files by giving each file a random name using a custom extension methods to the StringBuilder class to ensure there are no name collisions on the server. The then demonstrates how to resize the image to three specific sizes for use on the site using system.Drawing.Image.FromStream, system.Drawing.Imagein and more, discusses how to to maintain image aspect ratios, how to save as a PNG file type and more. Dave then discusses best practices for image manipulation in a web application. Finally, he implements the character count using a jQuery plugin called jQuery Limit.
In this final episode in Season 1, Dave adds the “search for user” functionality to look up other Twix members by some key word … their domain, a part of their name, etc. In doing so, he shows how to submit (and retrieve) a form using querystrings (HTTP GETs) in ASP.NET MVC. (Also talks about how to fix intellisense errors in the Visual Basic version of your ASP.NET MVC projects.)