Fix empty userName when running WebRazorPages by adding default username. (#80)

This commit is contained in:
Nud
2018-04-03 21:35:11 +07:00
committed by Steve Smith
parent 2c20807487
commit 0caba1a8e7
2 changed files with 2 additions and 1 deletions

View File

@@ -4,5 +4,6 @@
{ {
public const string BASKET_COOKIENAME = "eShop"; public const string BASKET_COOKIENAME = "eShop";
public const int ITEMS_PER_PAGE = 10; public const int ITEMS_PER_PAGE = 10;
public const string DEFAULT_USERNAME = "Guest";
} }
} }

View File

@@ -38,7 +38,7 @@ namespace Microsoft.eShopWeb.RazorPages.ViewComponents
{ {
return User.Identity.Name; return User.Identity.Name;
} }
return GetBasketIdFromCookie(); return GetBasketIdFromCookie() ?? Constants.DEFAULT_USERNAME;
} }
private string GetBasketIdFromCookie() private string GetBasketIdFromCookie()