Let me start by saying that what I have works - I just don't like it.
I have a web.sitemap that is used for my navigation bar. Some of the nodes are accessible by everyone, some of them have roles assigned (so that the node won't be shown to users who wouldn't be able to access it).
i.e. <siteMapNode url="~/adminpage.aspx" title="admin" roles="domain\Administrators"/>
Then, in my web.config, I have location elements like this:
<location path="adminpage.aspx">
<system.web>
<authorization>
<allow roles="domain\Administrators"/>
<deny roles="*"/>
</authorization>
</system.web>
</location>
In addition to this, some pages have hyperlinks that are shown or hidden based on roles, like this:
myHyperlink.Visible = Roles.IsUserInRole(@"domain\Administrators");
All of this works just fine - but... it seems a bit ridiculous. Is there any way to utilize the permissions established in my Web.config by the sitemap and Roles.IsUserInRole? Basically, I'm trying to prevent having the same permission descriptions in 435234 different places.
I attempted Casses solution to add embedded code in the sitemap file that would use settings from the web config - but that doesn't work (because you can't put embedded code in the sitemap file).