You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `null != ...` check looked strange, as it's usually written the other way around in C#. Rather than have a null check, just change this to a type check.
Copy file name to clipboardExpand all lines: xml/System.Security.Claims/ClaimsPrincipal.xml
+1-2
Original file line number
Diff line number
Diff line change
@@ -95,8 +95,7 @@
95
95
The following example extracts the claims presented by a user in an HTTP request and writes them to the HTTP response. The current user is read from the <xref:System.Web.HttpContext> as a <xref:System.Security.Claims.ClaimsPrincipal>. The claims are then read from it and then are written to the response.
96
96
97
97
```csharp
98
-
ClaimsPrincipal principal = HttpContext.Current.User as ClaimsPrincipal;
99
-
if (null != principal)
98
+
if (HttpContext.Current.User is ClaimsPrincipal principal)
0 commit comments