Wednesday, January 2, 2013

Restrict Access to Pages with “Roles” Property

Access to pages can be restricted by user roles with the “Roles” property. Any user that does not belong to a specified list of roles will not see the page in the navigation menu or be able to access the page by URL.

The Categories | Products page is visible for all authorized users in a default web application created from Northwind database. Let’s configure this page to only be visible for users with the role of “Administrators”.

Products page is available in the navigation menu.

Start the Project Designer. In the Project Explorer, double-click on Categories / Products page node.

Products page node in the Project Explorer.

Change the Roles property:

Property Value
Roles Administrators

Press OK to save. On the toolbar, press Browse.

Log in using the standard user account (user / user123%). The Products page will not be available in the navigation menu.

Products page is not available on the navigation menu.

If the URL is accessed directly (~/Pages/Products.aspx), the application will redirect you to the Home page.

When the user tries to access Products page by URL, the application will redirect to the Home page.

Log in with the administrative account (admin / admin123%). The page will now be available.

Products page is available in the navigation menu when logged in as 'admin'.

No comments:

You can find more about Code OnTime Generator, Data Aquarium Framework, and other great products here.


© 2010 Code OnTime LLC. Intelligent code generation software for ASP.NET. Visit us at http://codeontime.com