Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 394815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:23:34+00:00 2026-05-12T16:23:34+00:00

Edit: By Overriding the RoleProvider we were hoping to still use the same methods

  • 0

Edit: By Overriding the RoleProvider we were hoping to still use the same methods with our new methods. Such as Roles.GetRolesForUser(int).

 string[] myRoles3 = ((PortalRoleProvider) (Roles.Provider)).GetRolesForUser(2);

That above code seems a bit excessive ?

I have a class which overrides some members of the RoleProvider and adds new methods. Eg.

 public string[] GetRolesForUser(int UserId)
    {
        IEnumerable<Role> RoleList = _Repo.GetRolesForUser(UserId);


        string[] RetVal = new string[] {};

        foreach (var curRole in RoleList)
        {
            RetVal[RetVal.GetUpperBound(0)] = curRole.RoleName;
        }
        return RetVal;
    }

Now when I am in the logic of my code I want to write Roles.GetRolesForUser(2) but when i type this, it does seem to see the extra method that I have added. Here is the class declaration and the webconfig.

 namespace PortalMVC.Providers
 {
    public class PortalRoleProvider : RoleProvider
    {

Web.config

<roleManager enabled="true" defaultProvider="PortalRoleProvider">
    <providers>
        <clear/>
         <add name="PortalRoleProvider" type="PortalMVC.Providers.PortalRoleProvider"/>
    </providers>
</roleManager>

Any suggestions why this is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:23:34+00:00Added an answer on May 12, 2026 at 4:23 pm

    You have to cast your RoleProvider as your actual object type (i.e. PortalRoleProvider) to see the extra functions. This applies to any time you’ve extended a standard object but are accessing it as it’s super class (Master pages, etc.)

    string[] myRoles3 = ((PortalRoleProvider) (Roles.Provider)).GetRolesForUser(2);

    The above, as you’ve pointed out in your post, works. If you need to use this a lot in a section of code, you can create a pointer with the proper type then access the methods from there:


    PortableRoleProvider TempPointer=(PortableRoleProvider)Roles.Provider;

    string[] myRoles3=TempPointer.GetRolesForUser(2);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Java, and I've read over some tutorials on overriding methods, but
EDIT : Ok, I found out why. My getX and getY were overriding the
I'm trying to learn more about the .egg concept and overriding methods in Python.
Is there any way to use the slugs generated by overriding to_param in the
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
Edit (updated question) I have a simple C program: // it is not important
EDIT: iam using ajax to load text in my content that is why onload
Edit : Note that, as Daniel and latkin noted in an answer and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.