You must Sign In to post a response.
  • Category: ASP.NET

    How to get role of the user?

    Hi Friends,

    How to get role of the user in 4.0?
    when i was excute following code if(User.IsInRole("EDUser")) return error like "object not set" so coundnt root cause of the issue, but this same code is working fine my another appln 2.0 any one has implemented in 4.0 pls let me know ur thought with implemented source code..

    You people Rock!!!!!

    Thanks & advance
  • #721012

    Try to check like this

    using System.Web.Security;

    // to get logged user roles

    //if you are not targeting the current logged user.

    // if you want to check surrently logged in user for specific role:

    Check the below links to get more info on roles


  • #721018
    Hi Ramesh M,

    Whenever you try to bind empty data then you got this error "object reference not set to an instance of an object". Please check your data is there or not.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #721027
    Hai Ramesh,
    The issue is that you didnt set the roles using the Site Administration tool and you are checking the role.
    So before checking the user role by using the User.IsInRole("EDUser"), you need to set the security and users for your website.
    You can check in the Solution Explorer, the last icon names as security.
    By clicking on the icon,you will get the Site Administration tool where you can set the permission and user roles.
    After setting from there, now you can use your code which will check the current user with its role to perform the operations.
    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • #721059
    Can you try using :




  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.