I have a scenario where an anonymous user is to make a purchase and register for our site all at once. I have the following code on the checkout page:
//get order
OrderController orderCtlr = new OrderController();
Order order = orderCtlr.GetShoppingCart(WebUtility.GetUserName());
//user is new so register them and log them in
...
Go to the complete details ...