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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:37:28+00:00 2026-06-10T11:37:28+00:00

I am using role manager and windows authentication for my asp.net mvc project we

  • 0

I am using role manager and windows authentication for my asp.net mvc project
we have 2 Roles which are viewers and Editors .

    <authentication mode="Windows" />
    <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
        <providers>
          <clear />
          <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </roleManager>

Editor can access the whole application but Viewer can only access two actions

I first tried to put Authorize attribute for base controller which just allow editor to access everything :

[Authorize(Roles = "Editors")]
public class BaseController : Controller

and then add Authorize attribute to those two action:

[Authorize(Roles = "Viewers,Editors")]
public ActionResult Report(PaymentsUnallocatedAndQueriedModel model)

it does not work ,it does not allow viewer to access any action which make sense now.

I believe it is not a good idea to repeat Authorize attribute on the top of each action.

Could you please tell me if there is a better solution to that

  • 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-10T11:37:30+00:00Added an answer on June 10, 2026 at 11:37 am

    You have to look at this from a tree perspective. In order to get to an action, you must first be able to get to a controller. In this case, you’ve restricted the controller to the Editors group, so Viewers can’t even get that far. What would most likely be more helpful would be to restrict the controller to Viewers, Editors and then in the actions that require Editor only permission, specify those. This will generate redundant attributes, but consider the code cost if you had to manually restrict each action based on role membership.

    [Authorize(Roles = "Viewers, Editors")]
    public class BaseController : Controller
    {
    
        [Authorize(Roles = "Editors")]
        public ActionResult EditReport(PaymentsUnallocatedAndQueriedModel model)
        {
            // Some editor only functionality
        }
    
        public ActionResult Report(PaymentsUnallocatedAndQueriedModel model)
        {
            // Some functionality for both. No attribute needed
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Web Role that is using the ASP.NET SQL Membership provider. Currently
I'm using ASP.NET Roles with a special role Must Change Password. If a user
I have a little weird behavior with my ASP.NET MVC 2 application. I'm using
I have an asp.net web app that uses forms-based authentication, a SqlMembershipProvider (using an
I have an application that is using Windows Authentication and a SqlRoleProvider for user
I am using this guide: http://www.asp.net/mvc/tutorials/mvc-music-store-part-7 Like instructed, I entered to ASP.NET Web Application
I'm developing an ASP.NET MVC 4 website and I'm using the Microsoft ASP.NET Universal
I'm using ASP.NET Sitemaps with a custom Role Provider to generate a site Menu
I am using ASP.NET MVC to build a site. I am using VB as
I'm building an internal (intranet) MVC3 application using Windows Authentication and a custom role

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.