Understanding Javascript Promises

I have to admit I found the concept of Promises difficult to grasp at first; once I understood, I’ve been looking for a good way to explain it to others. This article is my attempt to make Promises easy to understand through a simple metaphor.


Imagine you’ve entered a crowded restaurant. You force your way to the maître d’ and request a table, and are told there is a wait. “We’ll call your name when the table is ready,” she says. This is the equivalent of a “callback” function – the server (a restaurant server in this case) will call you (the client) back when your request is complete. Inevitably half the people in the room are named “Bob” and a crowded confusion ensues.

Continue Reading

Stretching the (HTML 5) Canvas: Fixing Aspect Ratio Problems

The Problem

I’m working in a web part that uses the HTML 5 <canvas> element, and I ran into a little problem. The web part is a “microsurvey” that asks a single question and, when the user clicks an answer, displays the results of the survey so far. For the results, I wanted to show a bar chart, and I thought it would be a fun opportunity to use the new HTML 5 canvas. The problem is that my chart was distorted; as you can see the text is too wide and looks like it came off an old dot matrix printer. Somebody stretched the canvas!

3-9-2015 6-28-46 PM

Continue Reading

How to: Display the name of the Windows user logged into your ASP.NET Site

This article is reposted from my old MSDN blog. Please post comments here as I am no longer able to publish or respond to them on MSDN. Thanks!

This is really pretty simple but I was surprised not to find it in any one blog posting. The following code retrieves the display name of the logged in user, such as “Bob German” (not “domain\username”). It’s easy to accidentally display the Application Pool account rather than the logged in user. Some articles said to turn on Impersonation, but that’s often a bad idea for other reasons. This is what worked for me just now:

string username = &amp;quot;&amp;quot;;
IPrincipal userIdentity = HttpContext.Current.User;
PrincipalContext context =
    new PrincipalContext(ContextType.Domain);
UserPrincipal userPrincipal =
    UserPrincipal.FindByIdentity
        (context, userIdentity.Identity.Name);
if (userPrincipal != null)
{
    username = userPrincipal.DisplayName;
}

I hope this helps someone; thanks!

New Guidance from Microsoft for Packaging and Deploying SharePoint Solutions

This article is reposted from my old MSDN blog. Please post comments here as I am no longer able to publish or respond to them on MSDN. Thanks!


Microsoft is cleaning house. Now that it has to maintain SharePoint for thousands of enterprises and millions of users in Office 365, Microsoft is working to clean up all the odd and messy bits of its flagship collaboration product. In a recent training course on Microsoft Virtual Academy, Microsoft urged developers to change the way they package and deploy their code in order to clean up a mess that has been building since 2003.

Continue Reading

A Brand New Vantage Point

OldVantagePointWelcome – you have arrived at my new blog!

After nearly a decade blogging at MSDN, it’s time for me to strike out on my own. Microsoft was really nice to let me keep blogging after I left their employ to work at BlueMetal Architects, and Chris Bortlik was good enough to sponsor me (thanks Chris!) But alas, all good things must come to an end; a policy change means that partners can no longer post on MSDN.

So welcome to my new blog! As far as I know, Microsoft will leave my old articles where they are for the time being, and I plan to update some of them and re-post them here. Thanks for reading!