1

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?

JamesP
  • 195
  • 1
  • 3
  • 17

1 Answers1

1

There are several reasons not to change the file (though it might be possible):

  • The file is most likely located in the application directory of your application. If you change a file in this directory (e.g. web.config), IIS will restart the application so that other users might experience interruptions.
  • Also the SiteMapProvider might cache the file content for performance reasons, so that your changes are not reflected.
  • For security reasons the application pool account should not be able to modify files on the web server.

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.

Markus
  • 20,838
  • 4
  • 31
  • 55