WebExtensionsGetAccountIdFromCookie Method

Generates account user from ClaimsPrincipal. Note: the method assumes the user is logged in, and the cookies are present. Therefore, use this method in a try-catching block and redirect the user to the login page if the cookies aren't present.

Definition

Namespace: MobileTrack.Web.Components.Extensions
Assembly: MobileTrack.Web.Components (in MobileTrack.Web.Components.dll) Version: 0.7+ce90b2cf6b782b8d7b7fd47b3c546987c652c00f
public static void GetAccountIdFromCookie(
	this ClaimsPrincipal principal,
	out Guid accountId,
	out Guid companyId
)

Parameters

principal  ClaimsPrincipal
ClaimsPrincipal to convert.
accountId  Guid
Found Account ID in the cookie
companyId  Guid
Found Company ID in the cookie

Return Value

Account based on the ClaimsIdentity of the Principal.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ClaimsPrincipal. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullExceptionThrown if the cookies aren't present on the browser; redirect the user to login.
InvalidOperationExceptionThrown if the cookies aren't present on the browser; redirect the user to login.

See Also