I am starting a new member site based on umbraco. We need some pages which anonymous users can access but authenticated users shouldn't. I was looking into adding a default role in my custom membership provider but it is not called for anonymous users.
Using plain asp.net I would have made the following configuration in web.config for the proper locations.
Can we use any umbraco functionality to acheive this? The roles are working perfect to allow only authenticated users but this is the opposite way around.
For the navigation menu I am using the asp.net menu with the Umbraco MainNavigation sitemap provider (umbraco.presentation.nodeFactory.UmbracoSiteMapProvider) which seems to fit.
I guess it should be possible to use the umbrac.library:IsLoggedOn extension to check if a user is authenticated or not. If false show page otherwise don't...Could this be a solution?
Thank you for your answer. And use the check to determine both if the content should be shown and for rendering the navigation?
I am just using the asp.net menu, I have not a xslt for the navigation, I might have missed that this would require "customizations" - but if that it is the way to go I must start coding a menu (we have a fly-out menu which was out-of-the-box with the asp.net standard control.
Well if you have the .NET skills you should be able to make use of the umbraco.library in your C# code - but must admit that it's not what I'm best at. But you'll need to reference some of the binaries from Umbraco.
But yes, use the check to determine if a user can both access the page and if it's rendered in navigation.
There is a free video about it on umbraco.tv if I remember correctly.
But it's just a suggestion. Maybe there are other options available :-)
Thank for your answer Jan. I want to use the standard asp.net navigation control if ever possible, maybe also because that so far my .Net skills are better than my umbraco and so far it is much easier to test the many custom controls with standard asp.net and unit tests - and just make small adjustments to keep content in umbraco.
I ended with retreiving the source code for the default SiteMap provider and make adjustments to let the IsAccessibleToUser method "deny" access to the item (it is only for the navigation - there is no security in this). The umbraco SiteMapProvider is sealed so it is not possible to just extend it, instead I just copied the code.
I also made some refactoring and added support for alternative title fields and removal of the top "root" node. If this might be of interest to anyone I put the source for the SiteMapProvider below. With this approach I can still use my controls in a standard asp.net site (with the asp.net xmlsitemapprovider) and maintain content in umbraco and keep same behavior.
privateSiteMapNode CreateRootNode() { var topNode = newNode(-1); SiteMapNode result = null; if (topNode.Children.Count == 1) { // Use this as topnode result = CreateSitemapNode(topNode.Children[0]); } else { result = CreateNode("-1", "root", "umbraco root", "/", null, false); }
privateSiteMapNode CreateNode(string id, string name, string description, string url, string roles, bool onlyForAnonymous) { lock (this) { if (m_nodes.ContainsKey(id)) thrownew System.Configuration.Provider.ProviderException(String.Format("A node with id '{0}' already exists", id));
// If roles were specified, turn the list into a string array string[] rolelist = null; if (!String.IsNullOrEmpty(roles)) rolelist = roles.Split(newchar[] { ',', ';' }, 512);
Glad to hear you found a soltution and happy that you shared it in here.
It's only natural that you stick to the languages you know. But I think that for stuff like navigation you should look into use XSLT in the future. But of course it all depens on what you're trying to achieve.
But if you're in doubt about something you know where to ask :-)
I know xslt from my previous sitecore projects, so I am not afraid of that. However I think the asp.net menu gives nice, stylable and easy maintainable fly out menu which I haven't seen similar in xslt - but if I have overlooked something please point me in the right direction. Xslt is very flexiable and powerfull, but I always try to use existing controls to avoid re-coding built-in concepts and if the umbraco sitemap had supported this it would have been almost plug-and-play :)
If you have any questions about XSLT I'm sure people in here will be able to help you out. There are quite a few XSLT wizards in here (Chriztian Steinmeier and Lee Kelleher, Warren Buckley etc)
It should be possible to create the same effect using a combination of XSLT to output the HTML and then style it with CSS and create the effect using JavaScript. As it is now I can imagine that it may appear as M$ tag soup in the HTML source code...:-D
But I think that for now you should use what you know and keep your menu as it is. I'm sure it's great :-)
Hide page for authenticated users
Hi,
I am starting a new member site based on umbraco.
We need some pages which anonymous users can access but authenticated users shouldn't. I was looking into adding a default role in my custom membership provider but it is not called for anonymous users.
Using plain asp.net I would have made the following configuration in web.config for the proper locations.
Can we use any umbraco functionality to acheive this? The roles are working perfect to allow only authenticated users but this is the opposite way around.
For the navigation menu I am using the asp.net menu with the Umbraco MainNavigation sitemap provider (umbraco.presentation.nodeFactory.UmbracoSiteMapProvider) which seems to fit.
Thank you.
Kind regards,
Jesper
Hi Jesper
I guess it should be possible to use the umbrac.library:IsLoggedOn extension to check if a user is authenticated or not. If false show page otherwise don't...Could this be a solution?
/Jan
Hi Jan
Thank you for your answer.
And use the check to determine both if the content should be shown and for rendering the navigation?
I am just using the asp.net menu, I have not a xslt for the navigation, I might have missed that this would require "customizations" - but if that it is the way to go I must start coding a menu (we have a fly-out menu which was out-of-the-box with the asp.net standard control.
/Jesper
Hi Jesper
You're welcome and welcome to our by the way.
Well if you have the .NET skills you should be able to make use of the umbraco.library in your C# code - but must admit that it's not what I'm best at. But you'll need to reference some of the binaries from Umbraco.
But yes, use the check to determine if a user can both access the page and if it's rendered in navigation.
There is a free video about it on umbraco.tv if I remember correctly.
But it's just a suggestion. Maybe there are other options available :-)
Hi
Thank for your answer Jan.
I want to use the standard asp.net navigation control if ever possible, maybe also because that so far my .Net skills are better than my umbraco and so far it is much easier to test the many custom controls with standard asp.net and unit tests - and just make small adjustments to keep content in umbraco.
I ended with retreiving the source code for the default SiteMap provider and make adjustments to let the IsAccessibleToUser method "deny" access to the item (it is only for the navigation - there is no security in this). The umbraco SiteMapProvider is sealed so it is not possible to just extend it, instead I just copied the code.
I also made some refactoring and added support for alternative title fields and removal of the top "root" node. If this might be of interest to anyone I put the source for the SiteMapProvider below. With this approach I can still use my controls in a standard asp.net site (with the asp.net xmlsitemapprovider) and maintain content in umbraco and keep same behavior.
Please note that most of the code is from the umbraco source: http://umbraco.codeplex.com/SourceControl/changeset/view/0b8f67be2ca8#umbraco%2fpresentation%2fumbraco%2fnodeFactory%2fUmbracoSiteMapProvider.cs
Kind regards,
Jesper
Hi Jesper
Glad to hear you found a soltution and happy that you shared it in here.
It's only natural that you stick to the languages you know. But I think that for stuff like navigation you should look into use XSLT in the future. But of course it all depens on what you're trying to achieve.
But if you're in doubt about something you know where to ask :-)
Happy coding
/Jan
I know xslt from my previous sitecore projects, so I am not afraid of that. However I think the asp.net menu gives nice, stylable and easy maintainable fly out menu which I haven't seen similar in xslt - but if I have overlooked something please point me in the right direction. Xslt is very flexiable and powerfull, but I always try to use existing controls to avoid re-coding built-in concepts and if the umbraco sitemap had supported this it would have been almost plug-and-play :)
/Jesper
Haha...no need to be afraid! :-)
If you have any questions about XSLT I'm sure people in here will be able to help you out. There are quite a few XSLT wizards in here (Chriztian Steinmeier and Lee Kelleher, Warren Buckley etc)
It should be possible to create the same effect using a combination of XSLT to output the HTML and then style it with CSS and create the effect using JavaScript. As it is now I can imagine that it may appear as M$ tag soup in the HTML source code...:-D
But I think that for now you should use what you know and keep your menu as it is. I'm sure it's great :-)
/Jan
is working on a reply...