Adding a Controller4:29 with James Churchill
Now that we have our project, let’s add the first controller for our Comic Book Gallery website.
To follow along commiting your changes to this course, you'll need to fork the aspnet-comic-book-gallery repo. Then you can clone, commit, and push your changes to your fork like this:
git clone <your-fork>
git checkout tags/v1.5 -b adding-a-controller
In this video, we added a controller to our project by adding a C# class using the “Add > Class...” menu item. Using this method allowed us to understand what makes a C# class an ASP.NET MVC controller. While this method works, it’s not the typical way that developers add controllers to their ASP.NET MVC projects.
Visual Studio provides a feature called “scaffolding” that can be used to quickly and easily add items to a project. You can use scaffolding to add a controller to an ASP.NET MVC project by right-clicking on the “Controllers” folder and selecting the “Add > Controller…” menu item. That’ll open up the “Add Scaffold” dialog, which will present you with a list of controller templates to choose from.
For more information on how to add a controller to an ASP.NET MVC project use Visual Studio scaffolding see http://www.asp.net/mvc/overview/getting-started/introduction/adding-a-controller.
For more information on how to perform quick actions with light bulbs in Visual Studio, checkout out this MSDN page.
For more information about classes, access modifiers, and inheritance, check out these pages on MSDN.
CTRL+SHIFT+B- Build solution
You need to sign up for Treehouse in order to download course files.Sign up