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 7744397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:45:27+00:00 2026-06-01T09:45:27+00:00

This is a MVC 3 project. Just for testing, I have public class MyRoleProvider

  • 0

This is a MVC 3 project. Just for testing, I have

public class MyRoleProvider : RoleProvider
{
    public override string[] GetRolesForUser(string username)
    {
        return new string[] { "0", "1", "2", "4" };
    }

    public override bool IsUserInRole(string username, string roleName)
    {
        bool result = true;
        return result;
    }

I register it in web.config. And then, if I configure the standard SqlMemberShipProvider, something like the following will cause my GetRolesForUser to fire.

[Authorize(Roles="4")]
public class AdminController : Controller
{  //...

However, I don’t want to use the standard SqlMemberShipProvider. I defined by own AuthorizeAttribute as follows, just to test:

public class MyAuthorize : AuthorizeAttribute
{
    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        bool result = true;
        return result;
        return base.AuthorizeCore(httpContext);
    }

    protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
    {
        base.HandleUnauthorizedRequest(filterContext);
    }

    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        base.OnAuthorization(filterContext);
    }
}

Now, the following will not cause MyRoleProvider.GetRolesForUser to fire anymore.

[MyAuthorize(Roles="4")]
public class AdminController : Controller
{  //...

The above will trigger MyAuthorize.AuthorizeCore and MyAuthorize.OnAuthorization but not the methods in MyRoleProvider. What is the relationship between the MemberShipProvider, the RoleProvider and the AuthorizedAttribute? When are these relationships defined or configured?

Thanks.

  • 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-06-01T09:45:28+00:00Added an answer on June 1, 2026 at 9:45 am

    If you don’t want to use the standard SqlRoleProvider, don’t configure it. I usually comment it out or delete it.

    Your config will look something like this:

    <roleManager defaultProvider="MyRoleProvider" enabled="true">
      <providers>
        <clear />
        <!--<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />-->
        <add name="MyRoleProvider" type="Full.Namespace.Of.MyRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By default the MVC Preview 5 web project comes with a HomeController.vb class. This
First MVC project, just curious what the best way to manage this is. All
I have an asp.net MVC project hosting a silverlight application. I just started rebuilding
I have an ASP.NET MVC 3 project that I just created using the project
i have installed ckeditor into my asp.mvc project, now i need to implement just
Basically put, I have a MVC project and I just have the default route.
I just started an MVC 3 project using Forms Authentication. I have a web
I have written a VERY simple MVC application which just displays a single string
Hey guys, I'm doing an ASP.NET MVC project just for learning...and stuck in this...
I am lost on this MVC project I am working on. I also read

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.