[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

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

Posted on 2010-04-05
4
Medium Priority
?
239 Views
Last Modified: 2012-05-09
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
0
Comment
Question by:dantcho
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:Alfred A.
ID: 29795944
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
 
LVL 21

Accepted Solution

by:
Alfred A. earned 2000 total points
ID: 29796303
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
 

Author Closing Comment

by:dantcho
ID: 31710923
Excellent, simple to follow example and clearly explained.
0
 

Author Comment

by:dantcho
ID: 29798739
Perfect, tried and this does exactly what I wanted. Thank you very much for your help!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article, we will show how to detach and attach a database and then show how to repair a corrupt database and attach it, If it has some errors. We will show how to detach and attach using SSMS or using T-SQL sentences.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Suggested Courses
Course of the Month8 days, 6 hours left to enroll

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question