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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:24:46+00:00 2026-06-09T09:24:46+00:00

I m working on ASP.NET MVC 4 application.I have a dashboard and my users

  • 0

I m working on ASP.NET MVC 4 application.I have a dashboard and my users groups will be based on Windows Domain
So I am using WIndows Authentication for authenticating users.
I created sample applications which uses custom authentication by overrides functions AuthorizeAttribute, ActionFilterAttribute . Is this a good approach ?

  1. Which attribute is best used for authentication ?

I have a dashboard. So I need to show or hide the controls based on roles.
Suppose if there is 3 grids(table), If Admin is logs in, he can able see 3 grids(tables).
But if Support user is log in he can see 2 grids (table) only.

My plan is to create partial views for each grid and so there will be an Action and Controller for each partial view.
There will be a database and in that I will specify the actions which each group can perform. So that I can filter the requests.

2 How can I hide or show the partial views based on roles ?.

I tried some SO links, but all they are talking about 2,3 roles and it was hard coded.
In my case roles may vary and we uses db to set up access for roles.

Thanks in advance.

  • 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-09T09:24:48+00:00Added an answer on June 9, 2026 at 9:24 am

    I have done something similar. The way I did it (may not be the best)

    is to send a boolean back to the view

    in the controller use:

    bool showSection1 = true;
    bool showSection2 = false;
    
    ViewData["showSection1"] = showSection1;
    ViewData["showSection2"] = showSection2;
    /// may be better to use a viewmodel here rather than ViewData
    

    then in the view:

    @if((bool)ViewData["showSection1"])
    {
        @{Html.RenderPartial("section1");}
    }
    @if((bool)ViewData["showSection2"))
    {
        @{Html.RenderPartial("Section2");}
    }
    

    you will need to do the logic to set the boolean the way you want them but this should be a start.

    you could also create a static method that returns the role and then get that value directly from the view. this may be bad form though.

    @if(AppHelper.GetRole().equals("role1")){
        //show the partial
    }
    

    then create a class called AppHelper and a method called GetRole that returns the role of the user.

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

Sidebar

Related Questions

I'm working on a multi-tenant ASP.NET MVC application. So far we have been using
I am busy working with an ASP.NET MVC 3 application and using Windows 7.
I am working with an ASP.NET MVC application. I have one master page having
I am working on an asp.net MVC 3 application. I have a C# function
I am working on a Facebook tab application. I am using asp.net MVC 2
I am working on asp.net MVC 3 application. I have created a Razor view
I am working in an ASP.NET MVC Application. I have a view model as
I am working in ASP.NET 3.5 MVC application. We have a functionality where we
I am working on a ASP.NET MVC application where we have to write our
I am working on a asp.net mvc application. I have a situation where I

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.