Base solution for your next web application
Open Closed

AbpSession.UserId my user id is not a Long #253


User avatar
0
rafael sotelo created

Hi I'm using azure active directory for my WebApp, the user id is GUID given automatically by azure active directory, so im having problems with this code:

public long? UserId { get { var userId = Thread.CurrentPrincipal.Identity.GetUserId(); if (string.IsNullOrEmpty(userId)) { return null; }

            return Convert.ToInt64(userId);

Exception Details: System.FormatException: Input string was not in a correct format.

What can i do ?


2 Answer(s)
  • User Avatar
    0
    rafael sotelo created

    This is the value given by Azure:

    "NVmTdZoOF98hmb4fBA9eOvoCbF4TBQbOS_14OJwPXLM"

    Not exactly a GUID, but is an identifier given automatically when i logon using azure active directory

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    ABP assumes UserId as long. This is one of a few restrictions and it has many benefits to assume that while developing the framework (I answered this before in more detail before in forum and Github issues). I'm sorry for your situation. You may build some workaround, like handling request, mapping guid->long and replacing in CurrentPrincipal. If you can find a better way, please share with us. Thank you.