I have a website that has highly granulised access and hence requires many web.config files. The problem is I would like to trim the menu so that only certain users will have access to certain folders. I have enabled trimming and setup roles in the sitemap, however when I access the page the menu is not show, as I am authorized to view the default page which is not in a subfolder.
When I type the url of a page in sub folder’s I have access.
How should I handle this:
- A site map for each web.config file – don’t know how this will work
- Removing the sub web.config file to only use a single one
You don’t need a site map for each web.config file. When using the sitemap with a menu control and SitemapDataSource, ASP.NET will determine whether you have access to each page named in the sitemap through your configured MembershipProvider and/or RoleProvider, and if you do have access, the sitemap entry will be displayed in the Menu.
Note, that if you do not have access to all of the parents of an item in the sitemap, you will not be able to see that item. You can configure your SitemapDataSource with StartingNodeUrl to change where the root of the Menu is set within the sitemap.
As far as why you don’t see the default page in your Menu, if you can access the default page via entering the URL directly then the problem is most likely that you do not have the Menu or SitemapDataSource set up properly. For help with that, see: http://msdn.microsoft.com/en-us/library/ms227441.aspx and http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.menu.aspx#binding_to_data
If you need additional guidance I suggest you try to narrow down the exact cause of the issue, since Membership, Roles, Sitemaps and Menus are a pretty broad set of topics and there are tons of pitfalls that may occur. Get your Menus up and running without security trimming, and verify that Membership and Roles are working properly before you try to link the two.