Last week at Build, Scott Hanselsman and Jon Galloway presented a whirlwind tour of the new features coming to Visual Studio and ASP.NET. These features are meant to be additive to your experience as they will not impede any existing projects, but should help add more value moving forward. What’s the goal? Once a quarter they release some yummy goodies for Visual Studio that you can run with.
New “Cafeteria Style” Single Page Application template (with Knockout baked in)
The tooling now has new templates for Single Page application and Facebook application.
Web API Tracing
No longer are your Web API calls a mystical creature that is difficult to trace when something goes amiss. You can now see the tracing of your Web API calls in the debug window of Visual Studio. Very helpful to see what’s actually happening as you run your apps and browse around. It does this with the SystemDiagnosticsTraceWriter class.
Adding [Queryable] to your controller methods will add some OData features out of the box. So if you add that attribute, you can simply change your url to api/values/$top=5. The response can whip out some very tight JSON, too.
The returning JSON also adds in a small link to the next 5 records (this is baked into the JSON response). You can use the OData querystring to get the “next x” records or you can use a special method they expose in the results called __next (that is underscore underscore next) like this:
Windows Azure Authentication
You can publish your app to an Azure web site and add have your authentication process in place out of the gates. More from the ASP.NET web site:
Windows Azure Authentication makes it simple to enable authentication for web applications hosted on Windows Azure using Windows Azure Active Directory. You can authenticate Office365 users, corporate accounts synced from on-premise Active Directory or users created in your own custom Windows Azure Active Directory domain.
Damien Edwards and David Fowler introduced us to SignalR and now its been folded into the ASP.NET portfolio. There is a new file template in Visual Studio called the SignalR Hub class .
Facebook Auth and Apps
They’ve added a new Facebook C# SDK NuGet package that makes it much simpler to access Facebook auth. So what can you do? You can add the Facebook Authorize attribute to a controller action so it will bounce you over to Facebook’s auth and request specific types of permissions/access (like email, friends, etc). You can also grab a Facebook user and bind it to a local class and gain access to Facebook apps.
Single Page Application
The original template for Single Page Apps (SPA) made an appearance over a year ago in a preview and was later removed prior to VS 2012 being released. The first run at this template wasn’t really a template, but rather a specific way to create a SPA. This new template is a template . Kudos to Mads Kristensen for spearheading this at Microsoft. So what’s here? It’s a template that gets you started with the intent of helping you avoid the “blank page” syndrome and instead having a starting point for creating a SPA. Where you take it from there is up to you. This is especially important since there are many good ways to create a SPA. Here is their token ToDo demo which uses the template to start a ToDo app using Web API, MVC, jQuery, and Knockout:
The key takeaway here is not to model your SPA exactly how this template and demo do it, but rather to use it as a starting point to get you going. Scott H calls it a cafeteria plan, where you can choose what you want. I agree with that assessment too. It starts you out with ASP.NET MVC, ASP.NET Web API, Knockout.js, jQuery, modernizr, and some starter modules to get you going with SPA work. I dissect this a bit more in my post Inside the New Single Page Apps Template.