diff --git a/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs b/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs
index df0b4e5b9..55083dbc6 100644
--- a/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs
+++ b/src/Microsoft.Identity.Web.OWIN/AppBuilderExtension.cs
@@ -193,12 +193,12 @@ public static class AppBuilderExtension
httpContext.Session.Remove(ClaimConstants.ClientInfo);
}
- Claim nameClaim = context.AuthenticationTicket.Identity.FindFirst("preferred_username")
+ Claim? nameClaim = context.AuthenticationTicket.Identity.FindFirst("preferred_username")
?? context.AuthenticationTicket.Identity.FindFirst("name");
if (!string.IsNullOrEmpty(nameClaim?.Value))
{
- context.AuthenticationTicket.Identity.AddClaim(new Claim(ClaimTypes.Name, nameClaim.Value, string.Empty));
+ context.AuthenticationTicket.Identity.AddClaim(new Claim(ClaimTypes.Name, nameClaim?.Value, string.Empty));
}
return Task.CompletedTask;
diff --git a/tests/DevApps/aspnet-mvc/OwinWebApi/Web.config b/tests/DevApps/aspnet-mvc/OwinWebApi/Web.config
index 2e6b54221..077c2e16b 100644
--- a/tests/DevApps/aspnet-mvc/OwinWebApi/Web.config
+++ b/tests/DevApps/aspnet-mvc/OwinWebApi/Web.config
@@ -62,7 +62,7 @@
-
+
@@ -78,7 +78,7 @@
-
+
@@ -86,19 +86,19 @@
-
+
-
+
-
+
-
+
diff --git a/tests/DevApps/aspnet-mvc/OwinWebApp/Web.config b/tests/DevApps/aspnet-mvc/OwinWebApp/Web.config
index c4c51288b..2ccc489c2 100644
--- a/tests/DevApps/aspnet-mvc/OwinWebApp/Web.config
+++ b/tests/DevApps/aspnet-mvc/OwinWebApp/Web.config
@@ -63,7 +63,7 @@
-
+
@@ -79,7 +79,7 @@
-
+
@@ -87,19 +87,19 @@
-
+
-
+
-
+
-
+