Integrate Social Media Features: Developing the Fan Project
Developing the Visual Studio Fan Site
Finally, you are ready to roll up your sleeves and dive in to Visual Studio to create this cool Web application.
Creating Your New Project
Open Visual Studio, and from the menus select File / New / Project… The New Project dialog shows a hierarchy of categories on the left and a list of templates in the middle. The panel on the right gives you helpful information about the currently selected template.
As you can see the number of total templates is huge! What’s a template? It’s a set of files and settings that give you a running start toward creating a particular kind of application. Instead of starting from scratch, the basic stuff that you’d always have to do for an MVC Web application, for example, is done for you.
For this project, on the left you should choose Installed / Templates / Visual C# / Web. Then in the middle, select the ASP.NET Web Application. Give the project a name and click OK.
In the New ASP.NET Project window, select MVC. Click OK.
This is the page that greets you once the project is created. It briefly describes what’s in the project and provides links to help you get started.
The Joy of Visual Studio Templates
As you may know, creating an ASP.NET MVC Web app involves building and coordinating controllers, which contain the code that drives your application, views, which display information, and models, that allow data to be passed between controllers and views.
As you can see once your project is created, Controllers, Models and Views get their own folders. There are numerous other folders, too, including a place for fonts and one for client-side Scripts.
But as you can see Microsoft Visual Studio templates do much more than create folders. Three controllers, three models and over 20 views are created for you and provide a home page with About and Contact info pages built in. There’s also numerous pages for registering, logging in, resetting user passwords, etc. And all this is already themed with a low-key, professional look. This puts you in the driver’s seat, ready to get down to the real work of creating the Web app you imagine.
Visual Studio NuGet – Liberally Leveraging Libraries, the Easy Way
Of course Microsoft couldn’t anticipate everything that you might need for your project in the template. But to make adding additional features and libraries to your project easier, they provide the NuGet Browser.
In the past, adding code that others had written to a project could be complicated. With NuGet Browser, it’s as simple as shopping for free apps in an app store. Enter your search text and review the options that appear. A simple button click will copy down the appropriate files, add them to your project along with appropriate references and any other configuration necessary. It’s even smart enough to notice when you ask for a package that requires other packages to be installed first. It takes care of installing them all, in the correct order. And if later you decide to remove a package (and its dependencies) from your project, it backs it all out carefully, leaving your project as it was before it was added.
In this project, you want to use Google’s YouTube Data API. While you could handle creating the HTTP requests yourself, and processing the results, it’s much easier to use a Google-provided library that does all that for you.
From the Visual Studio menu, select Project / Manage NuGet Packages… The NuGet Package Manager tab appears. In the search textbox in the upper-right, type google.apis data v3. The one you want may not be at the top. Click on Google.Apis.YouTube.v3 Client Library.
Click the Install button on the right. When you do, that library, along with other required libraries, will be downloaded and installed. That’s all there is to it!