In my program, I have an option for Administrators to add new roles to the database. This, of course, utilizes the CreateRole
method from System.Web.Security.Roles
:
Roles.CreateRole(newRoleName);
Now I'm wondering, is it possible to modify my SiteMap
during run-time, in such a way that the new role could be added to the list of roles
in a given siteMapNode
? For example:
<siteMapNode title="Admin Tools" roles="Admin" description="">
if I where to insert a new Role called sampleRole
, the siteMapNode should look like this:
<siteMapNode title="Admin Tools" roles="Admin,sampleRole" description="">
how should my code behind look?
There are several reasons not to change the file (though it might be possible):
There is one alternative though: create a custom SiteMapProvider that determines the roles of the nodes so that it matches your requirements. See this link for details.