.comment-link {margin-left:.6em;}
Books & Articles I wrote.

Wednesday, March 01, 2006


Checking Page Security Programatically in ASP.Net 2.0

Ever wanted to programatically check whether someone has access to a particular page in .Net using the web.config configuration? Say for example you are building a menu and you don't want to have the web.config for access and roles AND then something that states what links they can click in the menu.

In other words, powerful security in ONE place.

This is a question i asked on the ASP.Net forums and Scott Guthrie, asp.net team lead, got back to me (at a non-sensible hour i may add!). Here is the solution, new in .Net 2.0.

if (UrlAuthorizationModule.CheckUrlAccessForPrincipal(
"~/Default2.aspx", User, "get")) {

// they have access

 read 0 comments | 

This page is powered by Blogger. Isn't yours?

Weblog Commenting and Trackback by HaloScan.com