Show All Modules to Anonymous Users

Topics: Web Client Software Factory
Mar 29, 2007 at 6:49 PM
I was wondering if it was possible, and what would be the best implementation, to show all available modules to anonymous users. But if they try to access any module, she must log in. Almost like a teaser, showing all available modules before logging in.

Logging in will cause the modules to then be filtered according to the user's permissions.
Coordinator
Mar 29, 2007 at 8:31 PM
Edited Mar 30, 2007 at 2:39 PM
Hi Mike,
Yes there is a (really simple) way to implement what you are looking for. You should create a class that inherits from Microsoft.Practices.CompositeWeb.Providers.ModuleSiteMapProvider. You should override the IsAccessibleToUser method in the following way, to check whether the user is authenticated.

public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
{
	if (check whether the user is anonymous here)
	{
		return true;
	}
	else
	{
		return base.IsAccessibleToUser(node);
	}
}

Once you've created this class, you should change the web.config settings to use this derived class instead of the previous one, in the system.web/siteMap section

Please let me know if this helps,
Julián Domínguez
http://staff.southworks.net/blogs/jdominguez
Mar 29, 2007 at 9:27 PM
Edited Mar 29, 2007 at 9:27 PM
This is very simple. Just one quick question. The actual class I'd be inheriting from should actually be ModuleSiteMapProvider correct? I don't see that method under SiteMapBuilderService.
Coordinator
Mar 30, 2007 at 2:38 PM
Yes, you're right, my mistake, you should inherit from Microsoft.Practices.CompositeWeb.Providers.ModuleSiteMapProvider.
I edited my previous post to avoid confusion in the future.