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

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!

Published Wednesday, October 31, 2012 5:42 PM by Jon Galloway

Comments

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

Great post, I approve of this message :-)

Thursday, November 1, 2012 2:00 AM by gblock

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

Hi Jon,

Is it safe to install this, and then later uninstall when the final goes out (without needing to worry about breakage to VS or projects created with it)?

Thanks,

Ben

Thursday, November 1, 2012 10:19 AM by BBach

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

So SPA doesn't seem fully functional without real time(SignalR). They should have added this.

Thursday, November 1, 2012 1:03 PM by Bond

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

I'm sorry (not really) but I cannot really get excited about any of this. it's the tools, always the tools. The name is ridiculous as it is (how long have we been complaining and still nobody cares?) but I think you should also drop ASP.NEt from the name.

Looking forward to new strength in the framework, not fad-ish Visual Studio templates.

Thursday, November 1, 2012 6:44 PM by Mike

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

Hi,

after exploring the new template for single page applications I could not found the nav.js.

Is it deprecated or just not released now?

Friday, November 2, 2012 5:34 AM by Andreas Schulz

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

Nice!  I always like having my life made easier as a developer.

Friday, November 2, 2012 10:21 AM by GrahameSD

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

Can I use it with VS 2010?

How Do I use this update with VS 2010?

Friday, November 2, 2012 11:26 AM by VJ

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

Nice one for C# developer, because I didn't found templates for Visual Basic section (i.e Single Page Application,SignalIR or Facebook Application).

Thank you,

Saturday, November 3, 2012 1:10 AM by Bassam Basamad

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

@BBach - Yes, this should be safe to install and later uninstall for the final. I've been testing pre-releases of this and have done the install-uninstall dance several times without any problems. That said, it is a preview release so it's not officially supported: www.asp.net/.../aspnet-fall-2012-update-release-notes

Saturday, November 3, 2012 4:01 PM by Jon Galloway

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

@Bond - That's an interesting idea, I'll ask about it. While it's not built into the SPA template, SignalR is shipped with the Fall Release so adding a hub is ridiculously easy.

Saturday, November 3, 2012 4:09 PM by Jon Galloway

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

@Bassam Basamad - Some of the templates aren't available in Visual Basic for the preview release, but all should be by the final release.

Saturday, November 3, 2012 4:11 PM by Jon Galloway

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

@VJ - This release is only supported on Visual Studio 2012. I don't think there will be an official release for Visual Studio 2010, but in the past some popular templates have had unofficial Visual Studio 2010 releases.

Saturday, November 3, 2012 4:36 PM by Jon Galloway

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

@Mike - No need to pretend to be sorry. :-)

(1) We're working on the name, it's likely it'll change for the release.

(2) There was a huge release (.NET 4.5, ASP.NET 4.5, ASP.NET MVC 4, ASP.NET Web API) just two months ago. This is a template / tooling update that makes it easier to take advantage of the last release. If you want new core features, grab the nightly releases and go to town.

Saturday, November 3, 2012 4:40 PM by Jon Galloway

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

Jon,

Great post. I watched the video of your talk at Build, really enjoyed watching it. But, your blog as well as on the official ASP.NET website, I couldn't find much details about the improvements made to Web Forms. Is the work on that still in progress?

Monday, November 5, 2012 7:10 AM by Ravi

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

nice post for us!thank u

Monday, November 5, 2012 8:31 PM by brautkleid verkaufen

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

Have you actually used Facebook C# SDK for various impl? it sucks man. It is a terrible SDK. I would definitely not integrate that into anything..

Tuesday, November 6, 2012 3:00 AM by Firat

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

@Bassam Basamad: Having the same issue trying to find the C# SPA template. I can see it in the templates folder, but not within the VS2012 IDE

Tuesday, November 6, 2012 7:18 AM by John Rossell

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

yeah It was a great learning experience!

Monday, November 26, 2012 10:02 PM by máy đo huyết áp

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

very good (wideweb)

Thursday, January 24, 2013 9:07 AM by web site design

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

good, thanks for this article

Saturday, February 2, 2013 2:45 PM by وی پی ان

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

Every adversity, every failure

tnxl

Wednesday, March 13, 2013 10:08 AM by وکیل

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

Black Rhinoceros - a eleemosynary and stalwart animal. he did not as weighty as the ghastly rhinoceros, but stilly powerful - reaches the authority 2-2, 2 m, lengths of up to 3, 15 m in height shoulders of 150-160 cm.

Monday, March 18, 2013 8:24 PM by SawVariavak

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

Hello! I just want to give a huge thumbs up for the great information you have

got here on this post. I will likely be coming

again to your blog for extra soon.

Monday, May 13, 2013 7:11 AM by Saenz