ASP.NET: Different Role --> Different versions of the same page?

Hello experts,

I have an asp.net application on my company's intranet. I am using windows authentication to capture the user's identity and active directory group. My application knows these AD groups as roles. I want to have three versions of an asp.net webform, each version tied to only a specific role.

There would be a data entry role that can only see the most limited page, a supervisor role that sees supervisory information that the data entry role cannot see, and an admin role that can see everything from the other two roles in one screen. How would I make it so that my application checks to see what role a user is part of, and based on that role decide what page to show them?

note: I already know that I can create folders in my website and give those folders their own web.config files that restrict use of a page to a specific role, and that isn't what I want to do, because then I would have to have three links for a user to click on and block certain links based on role. I want the user to AUTOMATICALLY come to the correct page for them based on their role and not ever have the option of clicking on the pages / folders of the other roles.

Please advise,
thank you
dantchoAsked:
Who is Participating?
 
Alfred A.Commented:
Hi,

Just some additional comment, I am providing a code snippet example for you to get an idea:

Page_Load in intermediate page:

protected void Page_Load(object sender, EventArgs e)
    {
        if(User.IsInRole("Manager"))
        {
            Response.Redirect("Manager.aspx");
        }
        else
        {
            Response.Redirect("Employee.aspx");
         }
    }
0
 
Alfred A.Commented:
Hi,

My suggestion is for you to redirect all users to a single intermediate page (in the page load for example) that inspects the user role and then appropriately, redirect a user again to the proper asp.net web page.

0
 
dantchoAuthor Commented:
Excellent, simple to follow example and clearly explained.
0
 
dantchoAuthor Commented:
Perfect, tried and this does exactly what I wanted. Thank you very much for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.