title: In asp.net mvc what is the use of context.User.Identity.Name?
body: <p>I'm currently studying asp.net mvc and I just started, I decided to move away from web forms to mvc.</p>
  
  <p>I'm following this tutorial from codeplex the mvc music store and there's this line of code that I don't understand how it's use and why it's use.</p>
  
  <p>Here is the line of the code:</p>
  
  <pre><code>if(!string.IsNullOrWhiteSpace(context.User.Identity.Name))
                  {
                      context.Session[CartSessionKey] = context.User.Identity.Name;
  
                  }
  </code></pre>
  
  <p>I would like to know what context.User.Identity.Name does because I tried removing the if block it's contained and the app still works.</p>
  
  <p>Here's the full code of that function:</p>
  
  <pre><code> public string GetCartId(HttpContextBase context)
          {
              if (context.Session[CartSessionKey] == null)
              {
                  if(!string.IsNullOrWhiteSpace(context.User.Identity.Name))
                  {
                      context.Session[CartSessionKey] = context.User.Identity.Name;
  
                  }
                  else
                  {
                      // Generate a new random GUID using System.Guid class
                      Guid tempCartId = Guid.NewGuid();
                      // Send tempCartId back to client as a cookie
                      context.Session[CartSessionKey] = tempCartId.ToString();
                  }
              }
              return context.Session[CartSessionKey].ToString();
          }
  </code></pre>