Jon Galloway

Interesting Things Circa March 2013

Back in 2008 I had a blog series going where I did occasional blog post / news recaps with lists of interesting things. (Fun note: I ran that using ma.gnolia.com and stopped around the same time, but not necessarily because, they bit the dust.). I used that to post interesting things I'd been reading about, and given unlimited time would write long, insightful blog posts about.

I've noticed lately that I've been declaring browser tab bankruptcy quite often, and that these interesting things deserved a home. Around that same time, I've started enjoying Scott Hanselman's fun, "no worries, have some links!" style newsletter posts lately. So, for an unspecified amount of time, I am reinstituting the "here's some neat stuff" series. I will intend to follow up with long, insightful posts about some of these things, but probably will not. On with the show!

Working from home

Yahoo recently required remote employees to stop being remote or stop being employees. As a remote employee since 2005, I can definitely see both sides. It works for some companies, some employee, and some roles. When it's good it's great, but I've seen it abused.

Goodbye Google Reader, what's ahead for RSS?

Google announced they're shutting down Google Reader. I used to follow 1500+ individual RSS feeds (actually read them all), but lately haven't quite so much. Still, sad to see this go and hope those who predict this will help rather than exterminate RSS as a technology are right.

Glimpse 1.0 Ships

Glimpse is a great web debugging aid which provides in-browser information about what's happening on the server. They recently released versions 1.0 and 1.1. We interviewed them on Herding Code in February.

Semantic Release Notes

The Glimpse developers also just released the Semantic Release Notes proposal: Semantic Release Notes (SRN) is a text-to-object-to-html conversion tool for application authors. SRN specifically aims to produce semantic release notes from a Markdown document. This allows authors to write using an easy-to-read, easy-to-write plain text document, convert it to a structured data format (typically JSON or XML) and from this format, convert it into any styled representation (typically html) or to consume the information programatically within 3rd party applications.

http://www.semanticreleasenotes.org/

scriptcs - Living on the edge in C# without a project on the wings of Roslyn and NuGet

Glenn Block and friends have spun up a neat project which allows you to write .NET apps with your favorite text editor, NuGet and the power of Roslyn!

CoffeeScript releases

Some cool new features in the recent CoffeeScript releases, including Literate CoffeeScript and Source Maps support.

Icon Fonts and SVG

As a long time fan of replacing web bitmap images (gif, jpg, png) with vector based formats when possible, I've been happy to see both the emergence of icon fonts as well as renewed interest in SVG for high-DPI display support.

Angular, Ember, brain hurt

Miscellany

Things I'm doing or involved with

Announcing Web Camps Spring Tour 2013

Whew! Seems like we just got back from the Winter tour, and we're off again! We've got eleven international events coming up in March and April. Some are already sold out, so register today! And let your friends and co-workers who don't read blogs know, too, because there

Web Camps are free, no fluff, lots of code events where you can get learn what's new in the Microsoft web platform and how you can put it to use right away. They're by developers for developers - no marketing, just building web apps.

Upcoming events

Here's the list, with speakers:

ASP.NET and Web Tools 2012.2 Content

We've updated this content to include the new ASP.NET and Web Tools 2012.2 release, including the new Visual Studio web tools updates, ASP.NET Web API features, new ASP.NET MVC templates. We organized the content so we start with tools and frameworks (e.g. ASP.NET MVC, ASP.NET Web API, Visual Studio, ASP.NET 4.5 Web Forms features), then dig into some specific scenarios for modern web application development. Here's the agenda:

  • Keynote: The ASP.NET Web Platform in Context
  • What’s new in ASP.NET 4.5 and Visual Studio 2012
  • Building and deploying websites with ASP.NET MVC 4
  • Creating HTML5 Applications with jQuery
  • Building a service layer with ASP.NET Web API
  • Leveraging your ASP.NET development skills to build apps for Office
  • Building and leveraging social web apps in ASP.NET
  • Building for the mobile web
  • Real-time communications with SignalR
  • Leveraging Windows Azure and Windows Azure Web Sites

Go on, register! And let your web dev friends and co-workers who don't read blogs know, too, because this is a great way for them to get a recap on what's going on with ASP.NET, Visual Studio 2012, HTML5, JavaScript, and more.

Building Web Apps with ASP.NET Jump Start - Over 6 hours of free ASP.NET video training

Last Friday Microsoft Learning hosted Scott Hansleman, Damian Edwards and me for a full day live video Jump Start event titled Building Web Apps with ASP.NET. We had a nice crowd of about 2,300 attendees joining us during the event - but we were really excited about ending up with a full day of top quality training on ASP.NET 4.5, ASP.NET MVC 4, ASP.NET Web API, SignalR, and Visual Studio - all updated for the ASP.NET and Web Tools 2012.2 release. The Microsoft Learning team has a great studio, event platform, and team, and I think the videos turned out great.

Thanks

This wouldn't have been possible without the heroic efforts of both Scott Hanselman and Damian Edwards. Scott hadn't been feeling well earlier that week, but presented an entire day of training immediately after a full week at the MVP Summit. Damian wasn't originally scheduled for this, but he was free that day and jumped right in - originally Scott and I invited him just to do the SignalR talk, but when we found he was available the whole day we asked him to help on a bunch of other sessions.

Thanks also to the whole Microsoft Learning team, especially Frank Gartland for setting this up. The Microsoft Virtual Academy puts out a lot of great content, including full courses which help you keep up with new releases (and prepare for certification exams if you're interested).

Content and Sample Code

This content was based on the courseware I just helped update for our current Web Camps tour. A lot of the demos are available in the Web Camps Training Kit, available here. We've got a bunch of free, one day Web Camp events going on over the next few months - with several more being added as we finalize dates and locations.

Videos

All nine sessions (over six hours) are up on Channel 9 - you can watch them online (HTML5 video or Silverlight) or download them in a bunch of MP4 or WMV formats. I've got them embedded below, too.

(01) What's New in ASP.NET 4.5

Sections:

[02:51] - Web development overview

This session starts by overviewing what we're going to cover in the series. The only way I can keep up with all the new releases the ASP.NET and Web Tools teams keep cranking out is to work out a mental map of how it all fits together. For the purpose of this day, we broke things into foundations and scenarios. The foundations include One ASP.NET (including ASP.NET Web Forms, ASP.NET MVC, ASP.NET Web API, and SignalR), Visual Studio, NuGet, and Azure - specifically Windows Azure Web Sites). After covering those tools, we look at using using them in some modern web development scenarios, such as social web applications, mobile web development, etc.

[10:48] - ASP.NET Web Forms model binding

ASP.NET 4.5 includes what I consider the biggest, most fundamental and transformative change to Web Forms since it was first released - model binding. I would have loved to have this years ago, and if you're doing ASP.NET Web Forms and not taking advantage of the new data control features, I really think you're both working too hard and writing lower quality code than you should be. The ASP.NET and Web Tools 2012.2 release includes Friendly URLs support, which gives you the full benefits of URL routing - both cleaner URLs and binding of URL values to control data access methods. My demo shows using the models from the MVC Music Store tutorial in an ASP.NET Web Forms application; it's available in the Web Camps Training Kit.

[20:27] - Bundling and Optimization

Bundling and Optimization is built in to ASP.NET 4.5, so it works across the platform. Scott shows a great example demonstrating bundling and optimization extensibility with both CoffeeScript and LESS minification.

[39:53] - Page inspector

The Visual Studio 2012 Page Inspector lets you interact with the output of your web pages inside of Visual Studio. It's conceptually similar to browser dev tools, but since it's integrated to your source it can give you a lot better information and feedback, answering questions like "Which view / partial view / user control / etc. is actually generating this HTML?" I demo'd the basic features, then showed the new live update feature in the ASP.NET and Web Tools 2012.2 release.

[43:58] - Async

ASP.NET 4.5 includes support for Async just about everywhere, including ASP.NET Web Forms, ASP.NET MVC controllers, etc. Scott shows a nice, simple example in which he changes three synchronous operations to run in parallel in an ASP.NET Web Form.

(02) Building and Deploying Websites with ASP.NET MVC 4

Okay, this one was fun up until my demo fail cliff hanger right at the end. I started with File / New Project, built out a simple ASP.NET MVC site, and deployed it to Windows Azure Web Sites.

[01:26] - Intro to ASP.NET MVC

No ASP.NET MVC talk is compete without a few diagrams, so I start with a review of the how ASP.NET MVC works, complete with some fancy animated diagrams.

[03:58] - Creating a new ASP.NET MVC site

In this part of the talk, I show the different ASP.NET MVC project template, tour through the folder structure, show how routing works, explain the standard conventions used in ASP.NET MVC, and show how the controllers and views work together.

[15:19] - Adding a model, controller, view

This part of the presentation shows how to work with data in an ASP.NET MVC application using models and scaffolding, with data backed by Entity Framework Code First. I set up Entity Framework Code First Migrations to keep changes to my data model synchronized with my database over time.

[34:57] - Deploying to Windows Azure Web Sites

With a complete, working application, it's time to deploy. To the cloud! Well, kind of. I was aware that if people are accessing your URL during a first deployment it can cause problems, but I'd never seen it in practice. Someone F5 bombed me and the deploy failed, which, was corrected by redeploying an unchanged web.config file to refresh the site. But, the cool part is that we built and deployed a site - complete with database and migrations - in under an hour. One of our attendees was so inspired that he created another site to encourage Scott to survive the day: http://scottwillpullthrough.azurewebsites.net/

(03) Creating HTML5 Applications with jQuery

[02:31] - Introduction to HTML5

Scott and Damian explain what HTML5 is, and what it means to you as a web developer, including an overview of modern web development features like responsive design.

[13:13] - HTML5 markup

Scott and Damian show how HTML5 semantic tags are included in ASP.NET MVC 4 and ASP.NET Web Forms 4.5 templates and explain why they're useful. They explain why feature detection is preferable to useragent sniffing and show how Modernizr makes doing the right thing easy.

[27:06] - jQuery overview

Scott and Damian show why everyone's using jQuery and overview the basics. Damian showed off a simple demo I put together that's up on jsbin: http://jsbin.com/ijucaq/2/edit (play along at home!)

[48:04] - Visual Studio web tools

Scott shows off a bunch of great new web development features in Visual Studio 2012 (including the 2012.2 updates and the Web Essentials extension) with some cool examples like HTML5 form elements and the new Single Page Application templates.

(04) Building a Service Layer with ASP.NET Web API

This is a whirlwind tour of ASP.NET Web API, including some new features in 2012.2 (Help Pages, Tracing, and OData).

[01:32] - Introduction to Web API

We start by looking at the File / New Project experience for the Web API template, covering Help Pages and Tracing.

[14:40] - Consuming Web API from jQuery

This sample showed using jQuery and the OData query syntax to page through server-side data.

[20:44] - Consuming Web API from Windows 8

One of the key reasons for using ASP.NET Web API is that you're able to work with any client type that can "speak HTTP" - including mobile and desktop applications. In this sample, I demonstrated a Windows Store application that was calling back into an ASP.NET Web API service.

(05) Leveraging Your ASP.NET Development Skills to Build Office Apps

You might not have heard that you can write Apps for Office using web technologies like HTML5, jQuery, and ASP.NET. It's really pretty slick. I thought it was so cool, I squeezed in a quick 15 minute talk to show it off.

[01:25] - HTML5 and jQuery for Office 2013

I start by showing a simple Hello World example, using jQuery to read and write Excel data into a task pane. Note: my demos require the Microsoft Office Developer Tools for Visual Studio 2012.

[07:53] - Adding ASP.NET Web API

This demo goes a bit further by showing an Excel Task Pane app that posts data back to a backing ASP.NET Web API service, then displays the result. Brady Gaster wrote this demo; it's available in the Web Camps Training Kit.

[12:24] - What is an App for Office

After having explained the model, I showed how you can get and sell Apps for Office in the store, then showed where you can find more information.

(06) Building and Leveraging Social Services in ASP.NET

Several people told me this was their favorite session. The scripted part is good - it shows how to let your users log into your ASP.NET applications using OAuth and OpenID, then explains the new Facebook app template in the 2012.2 release.

But our live viewers really liked watching the unscripted part, when Scott and Damian troubleshot a problem with Twitter app setup because Twitter wouldn't allow an authentication callback to Scott's laptop. Hilarity - but also some pretty slick, on the fly troubleshooting - ensued.

03:02] - OAuth flow

Scott and Damian explain how OAuth works, and how you can use it to enable users to log into your ASP.NET sites without a password.

[06:34] - Demo - OAuth and OpenID

Scott and Damian set up Twitter and Google authentication for an ASP.NET application.

[27:47] - Facebook applications

Scott and Damian explain how Facebook Aps work, then show how the new Facebook app template makes it a lot easier to develop Facebook applications and interact with the Facebook "social graph".

(07) Building for the Mobile Web

Scott shows three options for how to deal with the the ever-growing percentage of mobile browsers: do nothing, change the client (adaptive rendering), or change the server (display modes or using jQuery Mobile)

08:24] - Adaptive rendering - change the client

Scott shows you can use CSS @media queries to adapt the HTML for different display dimensions.

[11:24] - Display modes and jQuery Mobile - change the server

Scott shows how you can use ASP.NET MVC 4 display modes to create generic mobile views or custom, device specific views. He demonstrates how to use mobile browser emulators to test how the display modes will work on the target device. You can find out more about mobile device simulators here: http://www.asp.net/mobile/device-simulators

Scott's walkthrough on working with jQuery Mobile in ASP.NET is really worth watching - he demonstrates how to take advantage of some more advanced jQuery mobile features using the ASP.NET MVC 4 Mobile template. You can find out more about using the some of the techniques Scott demonstrates in this tutorial: ASP.NET MVC 4 Mobile Features.

(08) Real-time Communication with SignalR

SignalR makes it easy to do real-time web applications in ASP.NET. If you want to learn about SignalR - and I'd suggest that you do - Damian is the guy. He and David Fowler started developing SignalrR as an open source library two years ago, and he gives a really clear explanation that's both deeply technical and understandable.

[08:00] - Demo - Move shape

Damian shows a nice visual example with two browsers communicating via a SignalR backend; moving a shape in one browser instantly moves it in the other browser. You can find the code for this demo in the SignalR ASP.NET samples, titled ShapeShare.

[29:18] - Connecting to SignalR with C# and JavaScript clients

Damian demonstrates concurrent connections to the same hub from a WPF client and several different browsers.

[36:56] - Real-time gaming: ShootlR

Damian shows off the ShootR multiplayer HTML5 game, with over 260 live players. He explains the mechanics, including the different game loops and how they optimize for realtime multiplayer games. The code for ShootR is available here.

[44:20] - Chat application: JabbR

Damian shows off the JabbR chat system and talks about scaling with backplanes, then shows off some new features they're working on.

(09) Taking Advantage of Windows Azure Services

[01:20] - Azure signup

I explain the Azure signup process and talk about what you can get for free. Scott and I talked about how little it costs, and talked about how caching can make that even lower.

[05:00] - DevCamps.ms

I talk about how we've been using Windows Azure Web Sites for the DevCamps.ms site, and Scott and I talk about the ability to scale up and down. I also explain how we use separate Windows Azure Web Sites instances for QA and Staging on DevCamps.ms, using Git deploy. Scott and I discuss the ability to be able to roll back to previous Git deployments if needed.

[08:45] - Single serving sites

I show off a quick example of a "single serving" site for quick code demos.

[09:40] - Windows Azure Store

Scott and I talk about services - many free - which are available in the Windows Azure Store. I show off a demo what you get in the free version of New Relic.

[15:36] - Azure command line

Scott shows off all the sites he's running in Windows Azure and demonstrates how he can use the Azure command line to manage his sites. He explains that they're written in JavaScript and run cross-platform; for more information on that, see this tutorial: How to use the Windows Azure Command-Line Tools for Mac and Linux

[20:06] - Wrap-up

Scott, Damian and I wrap up the day with an overview of what we've covered and where you can go for more information.

Announcing the ASP.NET and Web Tools 2012.2 Release!

We're excited to announce the official release of ASP.NET and Web Tools 2012.2!

The most important thing to know about this release is that it doesn't affect the ASP.NET runtime or your existing projects and doesn't require any changes on your server. You can think of this as more of a Visual Studio web update that includes some new ASP.NET project templates. It works on my machine, is well behaved, and gentle around children and small pets.

I made a 25 minute video that overviews the features and shows a lot of code samples: Introduction to the ASP.NET and Web Tools 2012.2 Release:

Here's a summary (complete with some pretty pictures) and info on where to learn more.

What's in a name?

This release is named ASP.NET and Web Tools 2012.2, which is a bit of a mouthful. It's a tasty mouthful, though. Here's what it means:

ASP.NET - This release has new templates and tooling for the whole ASP.NET family: ASP.NET Web Forms, ASP.NET MVC, ASP.NET Web API, and more.

Web Tools - Historically, you had to wait for a big Visual Studio release to get updated features. That doesn't cut it these days, when a new language, JavaScript framework or SPA system goes up on Hacker News every week. In addition to the Web Essentials extension (which has nightly builds available if that's your style), the Visual Studio Web Tools team has worked hard to make it possible to officially ship new web features quickly. We just shipped Visual Studio 2012 last August, here's a bunch of new web tools for ya.

2012.2 - Naming is hard. The idea here is that this is a semantic name (or more semantic than Spring CTP Refresh Preview etc. etc.) that says this is an incremental release for the tools and templates that shipped with Visual Studio 2012.

What's in the box?

I made a handy diagram to explain the release. They tell me that software no longer ships in boxes, but if it did I think this should go on the cover:

What's new in Web Forms?

I really like ASP.NET 4.5 model binding and data control model updates. It brings a lot of the patterns I like in ASP.NET MVC to ASP.NET Web Forms, just scoped to the control level. Your data aware controls get and update data via methods which are control agnostic, the updates are model bound and validated, etc. It's quite nice.

The FriendlyURLs package helps you take advantage of that and push it further by bringing URLs inline with this model. It does two things for you:

  • It automatically maps URLs to ASPX pages
  • It automatically passes route values to controls with a nice bindable syntax

That means that you can have a URL like /Album/Edit/1 which maps to /Album/Edit.aspx, passing the 1 ID value so that controls can bind to it like this:

public Album EditAlbum_GetItem([FriendlyUrlSegments] int? id)
{
    return _db.Albums.Find(id);
}

 

What's new in SignalR?

Well, the main thing is that it's now ASP.NET SignalR. That means that, while it's still an open source project, it's officially shipped by and supported by Microsoft.

What's new in ASP.NET Web API?

Three big things:

Automatic Help Page generation - see a live sample here.

Tracing - Everything in the pipeline is output to the System.Diagnostics.Trace, so you can read it in the Visual Studio output window as well as any registered Trace Listener.

OData - Lots of new stuff here, including routing and query validation

ASP.NET MVC

ASP.NET MVC gets a few new templates, plus a big new bonus.

First, the Facebook template makes it easy to create full Facebook apps. Your users log in on Facebook, approve your requests to access their Facebook content, and then your app can interact with their social graph.

Secondly, there's a lightweight Single Page Application template based on Knockout.js and ASP.NET Web API.

And, thirdly, the big new bonus - we've made it possible to create new ASP.NET MVC templates using a Visual Studio extension (VSIX). Expect to see a lot more templates from us and others in the community!

What's new in Web Tools?

The web tools features are of course really visual, so I encourage you to watch the video above. Some highlights:

Page Inspector now has live sync, so when you update CSS you'll see it update immediately.

There's IntelliSense support for Knockout bindings, CoffeeScript, and more.

The integrated publishing includes single file publish and compare. That means that you can edit a single file and push it out, or even compare your local changes against the live production version.

Where do I get it?

As always, you can find the new release at http://asp.net/vnext

Where can I learn more?

Over the next two months we will have a series of new Web Camp events occurring around the world. We're finalizing several of them over the next few days.  Register today to attend one of these free one day events and learn how to build awesome web apps.

Building Web Apps with ASP.NET Jump Start with Jon Galloway and Scott Hanselman - Full Day Live (and recorded) Event on Feb 22

Update: Scott lost his voice, so we've had to postpone this event to Feb 22. It will be recorded so you can watch it online if the date change prevents you from watching live.

The ASP.NET and Web Tools teams have been cranking out some amazing stuff lately! But it can be a little tough to keep up with it all...

Lucky for you, we've got a great online event coming up on on February 22 which explains it all. Scott Hanselman and I are working with the Microsoft Learning / Virtual Academy team to run a full day Jump Start event. This will be live stream (register now!) and available on-demand later.

We'll be be spending a full eight hours digging into the following topics (and probably some more - who knows what will happen when you give Scott a microphone...):

  • New and advanced features in ASP.NET Web Forms
  • ASP.NET MVC 4 and ASP.NET Web API
  • jQuery
  • SignalR
  • Entity Framework
  • Visual Studio 2012
  • Internet Explorer 10 and HTML5
  • Building apps for Office with HTML5
  • Windows Azure Web Sites for ASP.NET developers

This is a great way to get up to speed with our latest releases, including everything you need to know about the ASP.NET and Web Tools 2012.2 release!

This is an online event, so everyone gets a front row seat. We'll be taking your live questions via chat, and we've got some top-notch chat proctors lined up including Brady Gaster and some ASP.NET MVP's. If you're familiar with our current Web Camps tour, this will follow the same general outline and content, but updated with the newest bits Scott and I can get our hands on!

Register now to reserve your spot.

And if you'd like a preview of some of the fun I fear we may all be in for, check out the talk Scott and I did at //build/, Bleeding edge ASP.NET: See what is next for MVC, Web API, SignalR and more…

Now imagine eight hours of this! What have I gotten myself into?

A quick look at Git support in Visual Studio 2012

I use Git a lot these days. My team uses it exclusively for internal work, collaboration with vendors, and public open source releases. I've got several public and private repos on CodePlex, GitHub and BitBucket - open source projects, book sample code, presentation content, etc.

I've used the command line, posh-git, and GitHub for Windows (you knew you can use GitHub for Windows with non-GitHub repositories, right?). I quickly decided that msysgit wasn't helpful, bounced between the command line and Visual Studio for a while, then used the git command line in the Visual Studio Package Manager console.

I've been using GitHub for Windows app a lot since it was released. Some people will make fun of you if you don't use the command line in git; and it's true that the old git windows tools weren't very useful. I've found that the GitHub for Windows client works pretty well for a lot of day to day work, and I can quickly pop open a shell window when I need it (e.g. removing files, merging, git deploy to Azure). If nothing else, GitHub for Windows takes the annoyance thinking about SSH keys out of the picture.

I wasn't sure I'd like GitHub support in Visual Studio, though. It's nice to see file status, history, merges, etc., but I didn't want it locking my files or messing with my project files or... well, changing anything at all. I think of code as files, not a bunch of stuff living in Visual Studio, and I want to manage it.

Disclaimer: There are a lot of good posts about the new Git support in Visual Studio 2012 with lots of nice pictures. I didn't read them, partly because it looked like a lot of work, and partly because I wanted to see if I could just click around and good things would happen. What could go wrong?

tl;dr: It doesn't mess with my code or project files, works well distributed, and integrates cleanly with stuff like .gitignore and .gitattributes. So far I like it. Oh, and it works with Visual Studio Express, too.

Installing the Git tools for Visual Studio 2012

The big Getting Started with Git in Visual Studio and Team Foundation Service post has a Get set up note at the top that worked great for me.

I already had Visual Studio 2012 installed, so step one was installing Visual Studio 2012 Update 2 CTP. I think the download page could be a little more clear - I figured I'd start with the smallest one and it worked on my machine.

Installing Visual Studio 2012 Update 2 CTP 22013-01-30_12h33_33

Note: In case you missed it, Visual Studio's moved to delivering regular updates (with new features) on a shorter delivery interval. Visual Studio 2012 Update 2, a.k.a. VS2012.2, just shipped and has a lot of nice new features (even a blue theme for the nostalgic).

The Visual Studio 2012 Update 2 install took 8 minutes for me and didn't require a reboot - make sure you've got Visual Studio closed when installing the update, of course. Not crazy fast, but barely long enough for me to get a cup of coffee.

Next up was the the Visual Studio Tools for Git extension. I expected this to be a little faster since it's a VSIX, but it was so fast I didn't get screenshot. It installed in maybe 15 seconds - if that. Fast. I, for one, welcome our new VSIX overlords. Fast, lightweight installs are quite nice, and I like that I can disable or uninstall them without fear of setting the house on fire.

Test drive (or, randomly clicking around to see what jumps out at me)

Okay, first I opened up a project I'd previously set up on GitHub. It found the .git folder and shows me status for files - none modified yet, as shown by the blue lock icon thing.

2013-01-31_20h31_33

I noticed a mistake in Default.aspx and deleted it, which shows a red checkmark to show it's been modified. It's pretty small, but I don't think that's a big deal as I'll show in a second.

2013-01-31_20h36_08

I also delete some database files from App_Data that shouldn't have been included. Now I'm ready to commit my change. I'll right-click on the project and pick "Commit..." Note that Commit was disabled until I made this change.

2013-01-31_20h38_27

Okay, now it popped up this Team Explorer thing which shows the changes I've made. The Commit button is disabled and it tells me I need a commit message (standard for a git commit), so I'll need to fill that in.

2013-01-31_20h41_05

After filling in the commit message, I can Commit.

2013-01-31_20h43_24

And then it shows the details from the Commit.

2013-01-31_21h14_08

Now at this point it still sees this as a local repo - it doesn't know that the upstream master is on GitHub. In the spirit of honest dumb guy clicking around, I don't see how to tell Visual Studio about the upstream master to push it.

2013-01-31_20h50_47

Hey, notice that little orange logo next to it? I didn't know what that was, either. It turns out it's the official Git logo. Who knew?

Fine, now let's check this out in GitHub for Windows to see if anything wacky happened.

2013-01-31_21h25_06

Sync from GitHub for Windows works, or I could pop the console and git pull --rebase / git push if I was in the mood.

Oh, one more neat thing - the branch history shows my local commit.

2013-01-31_21h30_08

Summary

I'm happy with this. I opened a project I'd previously created on GitHub, it didn't modify a single file, it read my .gitignore and .gitattributes, and it showed me some useful information. I just clicked around and (1) nothing got messed up (2) I saw some useful information as I was working. I guess that's my point - it didn't hurt anything and I'm happy I installed it.

I checked it out with my CodePlex git repos and they were swell, too.

From some more reading, the real goodness shows up when you use the free (for 5 users or with MSDN account) Git hosting at http://tfs.visualstudio.com, or when you need to do some merges or other more UI oriented things. You can read more from people who aren't just clicking around at some of the following gold certified urls:

Does ASP.NET Web API + OData filter at the database level? Let's ask IntelliTrace.

Someone asked me via Twitter if ASP.NET Web API queries are filtered at the database level, or if ASP.NET Web API queries the entire result set and then filters in code. Good question. I was pretty sure I knew the answer (below) but since everything in ASP.NET Web API changes so fast and they just released some big OData support updates, I wanted to make sure before answering.

How would you do that?

Option 1: Read the code

Since ASP.NET Web API and OData are both open source code, you can read through the code. A good guess at where to start would be the [Queryable] attribute:

http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/3dad0922b324#src/System.Web.Http.OData/QueryableAttribute.cs ExecuteQuery

private IQueryable ExecuteQuery(IEnumerable query, HttpRequestMessage request, HttpConfiguration configuration, HttpActionDescriptor actionDescriptor) 
{ 
    Type originalQueryType = query.GetType(); 
    Type entityClrType = TypeHelper.GetImplementedIEnumerableType(originalQueryType);

    if (entityClrType == null) 
    { 
        // The element type cannot be determined because the type of the content 
        // is not IEnumerable<T> or IQueryable<T>. 
        throw Error.InvalidOperation( 
            SRResources.FailedToRetrieveTypeToBuildEdmModel, 
            this.GetType().Name, 
            actionDescriptor.ActionName, 
            actionDescriptor.ControllerDescriptor.ControllerName, 
            originalQueryType.FullName); 
    }

    ODataQueryContext queryContext = CreateQueryContext(entityClrType, configuration, actionDescriptor); 
    ODataQueryOptions queryOptions = new ODataQueryOptions(queryContext, request); 
    ValidateQuery(request, queryOptions);

    // apply the query 
    IQueryable queryable = query as IQueryable; 
    if (queryable == null) 
    { 
        queryable = query.AsQueryable(); 
    }

    ODataQuerySettings querySettings = new ODataQuerySettings 
    { 
        EnsureStableOrdering = EnsureStableOrdering, 
        HandleNullPropagation = HandleNullPropagation, 
        MaxAnyAllExpressionDepth = MaxAnyAllExpressionDepth, 
        PageSize = _pageSize 
    };

    return queryOptions.ApplyTo(queryable, querySettings); 
}

Hmm. That's not manually filtering data, but the query itself is obviously a few levels deeper. Oh, let's look at the call stack:

System.Data.dll!System.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior behavior = {unknown}, string method = {unknown})    
System.Data.dll!System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(System.Data.CommandBehavior behavior = {unknown})    
System.Data.dll!System.Data.Common.DbCommand.ExecuteReader(System.Data.CommandBehavior behavior = {unknown})    
EntityFramework.dll!System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(System.Data.Entity.Core.EntityClient.EntityCommand entityCommand = {unknown}, System.Data.CommandBehavior behavior = {unknown})    
EntityFramework.dll!System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute(System.Data.Entity.Core.Objects.ObjectContext context = {unknown}, System.Data.Entity.Core.Objects.ObjectParameterCollection parameterValues = {unknown})    
EntityFramework.dll!System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(System.String (error) = Internal Error in IntelliTrace)    
EntityFramework.dll!System.Data.Entity.Core.Objects.ObjectQuery`1.AnonymousMethod()    
mscorlib.dll!System.Lazy`1.CreateValue()    
mscorlib.dll!System.Lazy`1.LazyInitValue()    
mscorlib.dll!Get System.Lazy`1.Value()    
EntityFramework.dll!System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()    
mscorlib.dll!System.Collections.Generic.List`1..ctor(System.Collections.Generic.IEnumerable collection = {unknown})    
System.Core.dll!System.Linq.Enumerable.ToList(System.Collections.Generic.IEnumerable source = {unknown})    
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonArrayContract.CreateWrapper(object list = {unknown})    
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Newtonsoft.Json.JsonWriter writer = {unknown}, object value = {unknown}, Newtonsoft.Json.Serialization.JsonContract valueContract = {unknown}, Newtonsoft.Json.Serialization.JsonProperty member = {unknown}, Newtonsoft.Json.Serialization.JsonContainerContract containerContract = {unknown}, Newtonsoft.Json.Serialization.JsonProperty containerProperty = {unknown})    
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(Newtonsoft.Json.JsonWriter jsonWriter = {unknown}, object value = {unknown})    
Newtonsoft.Json.dll!Newtonsoft.Json.JsonSerializer.SerializeInternal(Newtonsoft.Json.JsonWriter jsonWriter = {unknown}, object value = {unknown})    
Newtonsoft.Json.dll!Newtonsoft.Json.JsonSerializer.Serialize(Newtonsoft.Json.JsonWriter jsonWriter = {unknown}, object value = {unknown})    
System.Net.Http.Formatting.dll!<>c__DisplayClassd.<WriteToStreamAsync>b__c()    
System.Net.Http.Formatting.dll!System.Threading.Tasks.TaskHelpers.RunSynchronously(System.Action action = {unknown}, System.Threading.CancellationToken token = {unknown})    
System.Net.Http.Formatting.dll!System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStreamAsync(System.Type type = {unknown}, object value = {unknown}, System.IO.Stream writeStream = {unknown}, System.Net.Http.HttpContent content = {unknown}, System.Net.TransportContext transportContext = {unknown})    
System.Net.Http.Formatting.dll!System.Net.Http.ObjectContent.SerializeToStreamAsync(System.IO.Stream stream = {unknown}, System.Net.TransportContext context = {unknown})    
System.Net.Http.dll!System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream = {unknown}, System.Net.TransportContext context = {unknown})    
System.Net.Http.dll!System.Net.Http.HttpContent.CopyToAsync(System.IO.Stream stream = {unknown})    
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.WriteBufferedResponseContentAsync(System.Web.HttpContextBase httpContextBase = {unknown}, System.Net.Http.HttpContent responseContent = {unknown}, System.Net.Http.HttpRequestMessage request = {unknown})    
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.WriteResponseContentAsync(System.Web.HttpContextBase httpContextBase = {unknown}, System.Net.Http.HttpResponseMessage response = {unknown}, System.Net.Http.HttpRequestMessage request = {unknown})    
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.ConvertResponse(System.Web.HttpContextBase httpContextBase = {unknown}, System.Net.Http.HttpResponseMessage response = {unknown}, System.Net.Http.HttpRequestMessage request = {unknown})    
System.Web.Http.WebHost.dll!<>c__DisplayClass3.AnonymousMethod(System.Net.Http.HttpResponseMessage response = {unknown})    
System.Web.Http.WebHost.dll!<>c__DisplayClass3e`1.AnonymousMethod(System.Threading.Tasks.Task t = {unknown})    
System.Web.Http.WebHost.dll!System.Threading.Tasks.TaskHelpersExtensions.ThenImpl(TTask task = {unknown}, System.Func continuation = {unknown}, System.Threading.CancellationToken cancellationToken = {unknown}, bool runSynchronously = {unknown})    
System.Web.Http.WebHost.dll!System.Threading.Tasks.TaskHelpersExtensions.Then(System.Threading.Tasks.Task task = {unknown}, System.Func continuation = {unknown}, System.Threading.CancellationToken token = {unknown}, bool runSynchronously = {unknown})    
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.BeginProcessRequest(System.Web.HttpContextBase httpContextBase = {unknown}, System.AsyncCallback callback = {unknown}, object state = {unknown})    
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext httpContext = {unknown}, System.AsyncCallback callback = {unknown}, object state = {unknown})    
System.Web.dll!CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    
System.Web.dll!System.Web.HttpApplication.ExecuteStep(IExecutionStep step = {unknown}, ref bool completedSynchronously = {unknown})    
System.Web.dll!PipelineStepManager.ResumeSteps(System.Exception error = {unknown})    
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context = {unknown}, System.AsyncCallback cb = {unknown})    
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr = {unknown}, System.Web.HttpContext context = {unknown})    
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer = {unknown}, System.IntPtr nativeRequestContext = {unknown}, System.IntPtr moduleData = {unknown}, int flags = {unknown})    
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer = {unknown}, System.IntPtr nativeRequestContext = {unknown}, System.IntPtr moduleData = {unknown}, int flags = {unknown})    
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer = {unknown}, System.IntPtr nativeRequestContext = {unknown}, System.IntPtr moduleData = {unknown}, int flags = {unknown})    
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer = {unknown}, System.IntPtr nativeRequestContext = {unknown}, System.IntPtr moduleData = {unknown}, int flags = {unknown})

Okay, it's got to be in there somewhere. But looking for it seems like hard work. On to Option 2!

Option 2: Use IntelliTrace

If you've got Visual Studio Ultimate, this is one of those times you can enjoy your Ultimate Elite Preferred Coder status. View IntelliTrace Events using either Debug / IntelliTrace Events / View IntelliTrace Events or using keyboard shortcuts:

  • CTRL+ALT+Y, F <- Nice that there's a shortcut, but you're not going to remember this
  • CTRL+Q (Quick Launch) +  type "intellitrace events"  + hit Enter

Then scroll down the events list to see the ADO.NET calls and click on one that looks promising:

2012-12-22_18h50_46

Just to show the end result, here's the JSON result in the browser tools with the executed SQL query below:

ASP.NET Web API - OData Filtering

That query in text is:

SELECT 
[Extent1].[AlbumId] AS [AlbumId], 
[Extent1].[GenreId] AS [GenreId], 
[Extent1].[ArtistId] AS [ArtistId], 
[Extent1].[Title] AS [Title], 
[Extent1].[Price] AS [Price], 
[Extent1].[AlbumArtUrl] AS [AlbumArtUrl], 
[Extent2].[GenreId] AS [GenreId1], 
[Extent2].[Name] AS [Name], 
[Extent2].[Description] AS [Description], 
[Extent3].[ArtistId] AS [ArtistId1], 
[Extent3].[Name] AS [Name1] 
FROM   [dbo].[Albums] AS [Extent1] 
INNER JOIN [dbo].[Genres] AS [Extent2] ON [Extent1].[GenreId] = [Extent2].[GenreId] 
INNER JOIN [dbo].[Artists] AS [Extent3] ON [Extent1].[ArtistId] = [Extent3].[ArtistId] 
WHERE N'Kind of Blue' = [Extent1].[Title]

Final Answer: Yes

As long as your data provider supports deferred queries and you don't force evaluation by calling something like .ToList(), the query will not be evaluated until the OData filters are applied, and they'll be handled at the database level.

Announcing a Web Camps Winter World Tour starting December 2012

We have a great lineup of international Web Camps events scheduled for the next month. Come join us! Space for these events really is limited, so if you want to get in on them you need to sign up fast.

Web Camps: Free, one day events to show you how to make the most of the Microsoft web platform

Web Camps are an amazing opportunity to see how Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4 and Windows Azure fit together, and how you can put them to work today to solve real world problems, leveraging cutting edge web technologies.

ASP.NET today is about more than web pages

ASP.NET today is also about services running on ASP.NET Web API in the cloud, powering your Windows 8 applications, applications for Office, social website integration and more. ASP.NET on Windows Azure can be the hub that ties your development strategy together. This day's content is designed to show you how you can use the Microsoft web platform to rule - well, of course the web - but also the rest of the universe.

Play along! Learn, build and deploy working apps throughout the day!

Everyone knows that you learn best when you're doing, not just watching. And a website isn't done until it's deployed, right? So we'll be taking advantage of the free offerings from Windows Azure Web Sites to build and deploy working applications throughout the day, and we'll show you how you can, too, as you  follow along with us as we build and deploy multiple ASP.NET solutions to Windows Azure Web Sites throughout the day.

December Tour

Location Date Notes
Vancouver, Canada 4-Dec-12 With Brady Gaster and Xinyang Qiu and me. This one will be live streamed, and there's still a little more room at the event, too! Info here.
Stockholm, Sweden 10-Dec-12 With Nathen Totten and Mads Kristensen
Hong Kong 12-Dec-12 With Haishi Bai and Wenming Ye
Copenhagen, Denmark 12-Dec-12 With Nathen Totten and Mads Kristensen
Bangkok, Thailand 14-Dec-12 Me! Hopefully a special guest, too.
Singapore 17-Dec-12 Also me! Also maybe a special guest.

Details and registration links are on the DevCamps site: http://www.devcamps.ms/web/schedule

In the works (location and speaker TBD)

  • 1/28 - India
  • 1/30 - India
  • 2/18 - Germany
  • 2/20 - Russia

Want one in your area? Tell your local Microsoft developer evangelist folks!

Fresh Web content!

We are updating the Web Camps content to focus on putting the latest web platform releases to use. We will start the day with a look at the key building blocks (Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC and ASP.NET Web API) - including a look at the ASP.NET Fall 2012 Update announced at //build/. Then we will put them to work in a number of short targeted sessions focused on some key web application scenarios:

  • Keynote: The ASP.NET Web Platform in Context
  • What’s new in ASP.NET 4.5
  • Building and deploying websites with ASP.NET MVC 4
  • Creating HTML5 Applications with jQuery
  • Building a service layer with ASP.NET Web API
  • Leveraging your ASP.NET development skills to build apps for Office
  • Building and leveraging social web apps in ASP.NET
  • Building for the mobile web
  • Real-time communications with SignalR
  • Using Cloud Application Services

The full agenda is available here: http://www.devcamps.ms/web/agenda.   All of the slides, demos, and hands-on labs will be available for download at http://www.devcamps.ms/web/downloads quite soon.

Ten - oh, wait, eleven - Eleven things you should know about the ASP.NET Fall 2012 Update

Today, just a little over two months after the big ASP.NET 4.5 / ASP.NET MVC 4 / ASP.NET Web API / Visual Studio 2012 / Web Matrix 2 release, the first preview of the ASP.NET Fall 2012 Update is out. Here's what you need to know:

  1. There are no new framework bits in this release - there's no change or update to ASP.NET Core, ASP.NET MVC or Web Forms features. This means that you can start using it without any updates to your server, upgrade concerns, etc.
  2. This update is really an update to the project templates and Visual Studio tooling, conceptually similar to the ASP.NET MVC 3 Tools Update.
  3. It's a relatively lightweight install. It's a 41MB download. I've installed it many times and usually takes 5-7 minutes; it's never required a reboot. You can download it here.
  4. It adds some new project templates to ASP.NET MVC: Facebook Application and Single Page Application templates.
  5. It adds a lot of cool enhancements to ASP.NET Web API.
  6. It adds some tooling that makes it easy to take advantage of features like SignalR, Friendly URLs, and Windows Azure Authentication.
  7. Most of the new features are installed via NuGet packages - some from Microsoft, a few from the community.
  8. Since ASP.NET is open source, nightly NuGet packages are available, and the roadmap is published, most of this has really been publicly available for a while.
  9. The official name of this drop is the ASP.NET Fall 2012 Update BUILD Prerelease. Please do not attempt to say that ten times fast. While the EULA doesn't prohibit it, it WILL legally change your first name to Scott.
  10. As with all new releases, you can find out everything you need to know about the Fall Update at http://asp.net/vnext (especially the release notes!)
  11. I'm going to be showing all of this off, assisted by special guest code monkey Scott Hanselman, this Friday at BUILD: Bleeding edge ASP.NET: See what is next for MVC, Web API, SignalR and more… (and I've heard it will be livestreamed).

Let's look at some of those things in more detail.

No new bits

ASP.NET 4.5, MVC 4 and Web API have a lot of great core features. I see the goal of this update release as making it easier to put those features to use to solve some useful scenarios by taking advantage of NuGet packages and template code.

If you create a new ASP.NET MVC application using one of the new templates, you'll see that it's using the ASP.NET MVC 4 RTM NuGet package (4.0.20710.0):

This means you can install and use the Fall Update without any impact on your existing projects and no worries about upgrading or compatibility.

New Facebook Application Template

ASP.NET MVC 4 (and ASP.NET 4.5 Web Forms) included the ability to authenticate your users via OAuth and OpenID, so you could let users log in to your site using a Facebook account. One of the new changes in the Fall Update is a new template that makes it really easy to create full Facebook applications.

You could create Facebook application in ASP.NET already, you'd just need to go through a few steps:

  1. Search around to find a good Facebook NuGet package, like the Facebook C# SDK (written by my friend Nathan Totten and some other Facebook SDK brainiacs).
  2. Read the Facebook developer documentation to figure out how to authenticate and integrate with them.
  3. Write some code, debug it and repeat until you got something working.
  4. Get started with the application you'd originally wanted to write.

What this template does for you: eliminate steps 1-3.

Erik Porter, Nathan and some other experts built out the Facebook Application template so it automatically pulls in and configures the Facebook NuGet package and makes it really easy to take advantage of it in an ASP.NET MVC application.

One great example is the the way you access a Facebook user's information. Take a look at the following code in a File / New / MVC / Facebook Application site. First, the Home Controller Index action:

[FacebookAuthorize(Permissions = "email")]
public ActionResult Index(MyAppUser user, FacebookObjectList<MyAppUserFriend> userFriends)
{
    ViewBag.Message = "Modify this template to jump-start your Facebook application using ASP.NET MVC.";

    ViewBag.User = user;
    ViewBag.Friends = userFriends.Take(5);

    return View();
}

First, notice that there's a FacebookAuthorize attribute which requires the user is authenticated via Facebook and requires permissions to access their e-mail address. It binds to two things: a custom MyAppUser object and a list of friends. Let's look at the MyAppUser code:

using Microsoft.AspNet.Mvc.Facebook.Attributes;
using Microsoft.AspNet.Mvc.Facebook.Models;

// Add any fields you want to be saved for each user and specify the field name in the JSON coming back from Facebook
// https://developers.facebook.com/docs/reference/api/user/

namespace MvcApplication3.Models
{
    public class MyAppUser : FacebookUser
    {
        public string Name { get; set; }

        [FacebookField(FieldName = "picture", JsonField = "picture.data.url")]
        public string PictureUrl { get; set; }

        public string Email { get; set; }
    }
}

You can add in other custom fields if you want, but you can also just bind to a FacebookUser and it will automatically pull in the available fields. You can even just bind directly to a FacebookUser and check for what's available in debug mode, which makes it really easy to explore.

For more information and some walkthroughs on creating Facebook applications, see:

Single Page Application template

Early releases of ASP.NET MVC 4 included a Single Page Application template, but it was removed for the official release. There was a lot of interest in it, but it was kind of complex, as it handled features for things like data management. The new Single Page Application template that ships with the Fall Update is more lightweight. It uses Knockout.js on the client and ASP.NET Web API on the server, and it includes a sample application that shows how they all work together.

I think the real benefit of this application is that it shows a good pattern for using ASP.NET Web API and Knockout.js. For instance, it's easy to end up with a mess of JavaScript when you're building out a client-side application. This template uses three separate JavaScript files (delivered via a Bundle, of course):

  • todoList.js - this is where the main client-side logic lives
  • todoList.dataAccess.js - this defines how the client-side application interacts with the back-end services
  • todoList.bindings.js - this is where you set up events and overrides for the Knockout bindings - for instance, hooking up jQuery validation and defining some client-side events

This is a fun one to play with, because you can just create a new Single Page Application and hit F5.

Quick, easy install (with one gotcha)

One of the cool engineering changes for this release is a big update to the installer to make it more lightweight and efficient. I've been running nightly builds of this for a few weeks to prep for my BUILD demos, and the install has been really quick and easy to use. The install takes about 5 minutes, has never required a reboot for me, and the uninstall is just as simple.

There's one gotcha, though. In this preview release, you may hit an issue that will require you to uninstall and re-install the NuGet VSIX package. The problem comes up when you create a new MVC application and see this dialog:

The solution, as explained in the release notes, is to uninstall and re-install the NuGet VSIX package:

  1. Start Visual Studio 2012 as an Administrator
  2. Go to Tools->Extensions and Updates and uninstall NuGet.
  3. Close Visual Studio
  4. Navigate to the ASP.NET Fall 2012 Update installation folder:
    1. For Visual Studio 2012: Program Files\Microsoft ASP.NET\ASP.NET Web Stack\Visual Studio 2012
    2. For Visual Studio 2012 Express for Web: Program Files\Microsoft ASP.NET\ASP.NET Web Stack\Visual Studio Express 2012 for Web
  5. Double click on the NuGet.Tools.vsix to reinstall NuGet

This took me under a minute to do, and I was up and running.

ASP.NET Web API Update Extravaganza!

Uh, the Web API team is out of hand. They added a ton of new stuff: OData support, Tracing, and API Help Page generation.

OData support

Some people like OData. Some people start twitching when you mention it. If you're in the first group, this is for you. You can add a [Queryable] attribute to an API that returns an IQueryable<Whatever> and you get OData query support from your clients. Then, without any extra changes to your client or server code, your clients can send filters like this: /Suppliers?$filter=Name eq ‘Microsoft’

For more information about OData support in ASP.NET Web API, see Alex James' mega-post about it: OData support in ASP.NET Web API

ASP.NET Web API Tracing

Tracing makes it really easy to leverage the .NET Tracing system from within your ASP.NET Web API's. If you look at the \App_Start\WebApiConfig.cs file in new ASP.NET Web API project, you'll see a call to TraceConfig.Register(config). That calls into some code in the new \App_Start\TraceConfig.cs file:

public static void Register(HttpConfiguration configuration)
{
    if (configuration == null)
    {
        throw new ArgumentNullException("configuration");
    }

    SystemDiagnosticsTraceWriter traceWriter =
        new SystemDiagnosticsTraceWriter()
        {
            MinimumLevel = TraceLevel.Info,
            IsVerbose = false
        };

    configuration.Services.Replace(typeof(ITraceWriter), traceWriter);
}

As you can see, this is using the standard trace system, so you can extend it to any other trace listeners you'd like. To see how it works with the built in diagnostics trace writer, just run the application call some API's, and look at the Visual Studio Output window:

iisexpress.exe Information: 0 : Request, Method=GET, Url=http://localhost:11147/api/Values, Message='http://localhost:11147/api/Values'
iisexpress.exe Information: 0 : Message='Values', Operation=DefaultHttpControllerSelector.SelectController
iisexpress.exe Information: 0 : Message='WebAPI.Controllers.ValuesController', Operation=DefaultHttpControllerActivator.Create
iisexpress.exe Information: 0 : Message='WebAPI.Controllers.ValuesController', Operation=HttpControllerDescriptor.CreateController
iisexpress.exe Information: 0 : Message='Selected action 'Get()'', Operation=ApiControllerActionSelector.SelectAction
iisexpress.exe Information: 0 : Operation=HttpActionBinding.ExecuteBindingAsync
iisexpress.exe Information: 0 : Operation=QueryableAttribute.ActionExecuting
iisexpress.exe Information: 0 : Message='Action returned 'System.String[]'', Operation=ReflectedHttpActionDescriptor.ExecuteAsync
iisexpress.exe Information: 0 : Message='Will use same 'JsonMediaTypeFormatter' formatter', Operation=JsonMediaTypeFormatter.GetPerRequestFormatterInstance
iisexpress.exe Information: 0 : Message='Selected formatter='JsonMediaTypeFormatter', content-type='application/json; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate
iisexpress.exe Information: 0 : Operation=ApiControllerActionInvoker.InvokeActionAsync, Status=200 (OK)
iisexpress.exe Information: 0 : Operation=QueryableAttribute.ActionExecuted, Status=200 (OK)
iisexpress.exe Information: 0 : Operation=ValuesController.ExecuteAsync, Status=200 (OK)
iisexpress.exe Information: 0 : Response, Status=200 (OK), Method=GET, Url=http://localhost:11147/api/Values, Message='Content-type='application/json; charset=utf-8', content-length=unknown'
iisexpress.exe Information: 0 : Operation=JsonMediaTypeFormatter.WriteToStreamAsync
iisexpress.exe Information: 0 : Operation=ValuesController.Dispose

API Help Page

When you create a new ASP.NET Web API project, you'll see an API link in the header:

Clicking the API link shows generated help documentation for your ASP.NET Web API controllers:

And clicking on any of those APIs shows specific information:

What's great is that this information is dynamically generated, so if you add your own new APIs it will automatically show useful and up to date help. This system is also completely extensible, so you can generate documentation in other formats or customize the HTML help as much as you'd like. The Help generation code is all included in an ASP.NET MVC Area:

SignalR

SignalR is a really slick open source project that was started by some ASP.NET team members in their spare time to add real-time communications capabilities to ASP.NET - and .NET applications in general. It allows you to handle long running communications channels between your server and multiple connected clients using the best communications channel they can both support - websockets if available, falling back all the way to old technologies like long polling if necessary for old browsers.

SignalR remains an open source project, but now it's being included in ASP.NET (also open source, hooray!). That means there's real, official ASP.NET engineering work being put into SignalR, and it's even easier to use in an ASP.NET application. Now in any ASP.NET project type, you can right-click / Add / New Item... SignalR Hub or Persistent Connection.

And much more...

There's quite a bit more. You can find more info at http://asp.net/vnext, and we'll be adding more content as fast as we can. Watch my BUILD talk to see as I demonstrate these and other features in the ASP.NET Fall 2012 Update, as well as some other even futurey-er stuff!

Professional ASP.NET MVC 4 is out!

Look what showed up yesterday!

Note: These bobsledders on the cover may look familiar, but they have in fact been upgraded to ASP.NET MVC 4.

Up on Amazon

Professional ASP.NET MVC 4 is available on Amazon, both in paperback and Kindle format. At least in the US, I hear they're shipping these out really fast.

E-Book Versions

There are two E-book options, both with some nice features.

The Kindle version is in color and allows you to do all the standard Kindle font size / background / layout tweaking. I think they turned out pretty nice:

2012-09-26_16h29_39

2012-09-26_16h27_47

The other option is to get the e-book versions from Wrox. Those aren't in color, but they're available in three formats (PDF, Mobi, and ePub) and they're DRM free. I don't think they're available yet, but should be up in early October.

What's New

For this book, we focused on a few main things:

  • Updates for ASP.NET MVC 4 and Visual Studio 2012
  • More professional / advanced / real-world content
  • Better flow for people who are new to ASP.NET MVC - or are experienced with it
  • Responding to feedback and reviews
  • ASP.NET Web API

Updates

Obviously, we updated the content, code and screenshots for ASP.NET MVC 4 and Visual Studio 2012. Some of the implications of the updates aren't immediately obvious, though - for instance, I felt that the security chapter should consider the implications of OAuth and OpenID authentication.

Professional / Advanced / Real World Content

One bit of feedback we heard from the previous book was that it didn't have enough "real world" content. That can be kind of tricky, but it's a fair criticism. For this version of the book, we focused on two areas for that. First, we reviewed the content so that the content would flow a bit better for different skill levels - more on that next. Secondly , Phil wrote a new chapter at the very end of the book that explains how he and other ASP.NET MVC pros built and maintain the NuGet Gallery site at NuGet.org. He covers things like exception logging, profiling, data access, migration and membership.

Better Flow

I had some beginning developers tell me that the book started throwing advanced concepts at them too early, while some advanced developers told me the book seemed too basic. After talking to people in more depth, this was really the same problem - the book's flow needed to improve. We worked to make the book build more evenly, so it starts easier at the beginning and adds in more advanced content later. While this benefits the beginner, it also lets advanced developers skip over the simple stuff and jump into meaty chapters later in the book without interruptions to teach them the basics.

It's not exact, but in general Chapters 1-6 cover the basics and Chapters 7-16 cover intermediate and advanced content. So as an advanced developer, I'd recommend reading Chapter 1 to get the overview of what's new in ASP.NET MVC 4, then skimming chapters 2-6 (controllers, models, views, Ajax, and data annotations) and reading more thoroughly starting with Chapter 7 on Security.  One example of that is Chapter 3 on Views - it now focuses more on the beginner level stuff you need to know, and the advanced view information (like custom view engines) is covered in the Views section of the Advanced Topics chapter.

The table of contents is available as a PDF, take a look and see how we did.

Responding to feedback and reviews

We do take reviews - both positive and negative - seriously. We read through comments from the previous book and did our best to keep making the book better.

ASP.NET Web API

ASP.NET Web API is a big subject, and really an entire book could easily be written on it. However, since it ships with ASP.NET MVC 4 and is so useful in ASP.NET MVC applications, we felt like it would be good to have a one chapter overview. Brad wrote a great overview that explains not just what ASP.NET Web API is, but how it fits in with ASP.NET MVC.

What's Not New

Same amazing author team, same way to get the sample code (NuGet), same technical editor, same bobsledders. Oh, but the bobsledders have been upgraded, remember.

And speaking of our technical editor, I want to call out what an amazing job Eilon Lipton does on this book. In additional to top notch technical feedback, he also regularly points out bigger issues in structure and content. He regularly recommends that we cover content or features we'd left out, or that we stop recommending something that's not a good idea, or just tells us that a part of a chapter is boring or hard to follow. The book wouldn't be what it is without his invaluable input.

The whole team at Wrox has been great, too. It's both humbling and incredibly rewarding to work with a sharp editorial team, and this was another great experience.

But I already have a previous edition!

Weren't you listening? There's tons of new content. This book is about ASP.NET MVC 4 and ASP.NET Web API, what's your old book about?

Look, you can still use your old copies of the book for other things. For instance, the whole bobsled book family makes a great play set... and the holidays are coming soon...

Oh, and also Amazon's got it incredibly cheap now, so there's that. So go get it!

More Posts Next page »