Adding roles using AddUserToRole(string username, string roleName) does not work sometimes RRS feed

  • Question

  • We are working on an ASP.NET Web Forms application using ASP.NET Membership for user related operations. When a user is created in the application, we add him to two roles, a main and a sub role, as per the below code snippet.

    Roles.AddUserToRole(userName, mainRoleName);
    if (mainRoleName == "Test")
        Roles.AddUserToRole(userName, subRoleName);

    Rarely, we face an issue where the user gets added to the subRoleName but is not part of the mainRoleName. Is there any specific reason for this to happen and anyone faced similar issues like the one mentioned?

    Sunday, September 20, 2020 5:48 PM

All replies

  • Hi Shriram Sankaran,

    Thank you for posting here.

    According to your description, your issue is more related to ASP.NET. Therefore, it will be more appropriate to ask your question in ASP.NET forums. Thanks.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 21, 2020 1:26 AM