hiding sitemap pages in 1.3.0

Topics: Developer Forum, User Forum
Apr 16, 2010 at 3:11 PM

since more than 2 weeks, on and off, I'm trying to hide pages in the Menu based on roles.
Obviously without success!

In the discussion list I have seen similar issues but did NOT find an answer.
Appreciate if somebody can guide me in the right direction .... I might miss something very simple, I guess!?

see my scenario below!

Thanks for your time
ed

my scenario:
In WEB.config:
<add name="CustomXmlSitemapProvider" type="MyWebPagesStarterKit.Providers.CustomXmlSitemapProvider" securityTrimmingEnabled="true" siteMapFile="~/App_Data/Web.sitemap"/>
and
  <system.web>
   <authorization>
    <allow roles = "Administrators, membre"/>
    <deny users = "*"/>
   </authorization>
  </system.web>
 </location>

As far as I understand these are the two relevant pieces!
When I run this I still see News (aspx) in the menu, HOWEVER, when clicking News I get directed to the 'Login' screen. I.e. mwpsk obviously did something to sort of 'hide' News which is: I cannot acces it BUT: I would like to hide the menu item altogether.
PS: with the check box blank for 'Visible' (administration --> Navigation) i.e. Non-visible; I do NOT see the page for any roles except Administarators - which I think is correct!?

In case you want to see the web.sitemap:

<?xml version="1.0" encoding="utf-8"?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
  <siteMapNode>
    <siteMapNode url="~/administration/default.aspx" title="Administration">
      <siteMapNode url="~/administration/website.aspx" title="CMS Setup" />
      <siteMapNode url="~/administration/sections.aspx" title="Sections/Page Assignment" />
      <siteMapNode url="~/administration/navigation.aspx" title="Pages and Navigation" />
      <siteMapNode url="~/administration/users.aspx" title="User Management" />
    </siteMapNode>
    <siteMapNode title="Accueil" url="~/accueil.aspx" visible="True" pageId="123d2cb2-0e92-4bc2-8295-ba6c5ad036d4" />
    <siteMapNode title="News" url="~/news.aspx" visible="True" pageId="8cc81aca-80b8-4e65-a419-f00fd29d671e" />
    <siteMapNode title="Compétitions" url="~/competitions.aspx" visible="True" pageId="5f314800-afdc-46f3-a8d1-f8e3ada36af6" />
  </siteMapNode>
</siteMap>

 


 

Apr 16, 2010 at 4:40 PM
Edited Apr 16, 2010 at 5:03 PM

I had problems too, and I think there are bugs in this part of MWPSK.

See my posts http://mywebpagesstarterkit.codeplex.com/Thread/View.aspx?ThreadId=209043

http://mywebpagesstarterkit.codeplex.com/Thread/View.aspx?ThreadId=209047

I found it worked better after I switched from the custom xml sitemap provider to the standard xml sitemap provider in web.config

    <!-- standard (non MWPSK) sitemap provider -->
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
      <providers>
        <clear/>
        <add name="XmlSiteMapProvider" description="Default SiteMap provider." type="System.Web.XmlSiteMapProvider" siteMapFile="~/App_Data/web.sitemap" securityTrimmingEnabled="true"/>
      </providers>
    </siteMap>

I also use Sqlmembership and roles providers.

I put roles in the app_data/web.sitemap like this ...

    <siteMapNode title="Database Maint" url="~/db.aspx" visible="True" pageId="4a4f9f1c-eaf4-45c5-a808-615e853ea130" roles="dbmaint, Administrators">
      <siteMapNode title="EventTypes" url="~/db/eventtypesmaint.aspx" visible="True" pageId="1a78eb3f-9c24-4169-a2bb-ebdbad9090d4" />
      <siteMapNode title="Events Maintenance" url="~/db/eventsmaint.aspx" visible="True" pageId="17b229a3-405f-4499-9604-d35b56b04c04" />

...

   </siteMapNode>

Do not allow anonymous access for the pages you want to hide.

I found that switching off "visible" did not work as I thought it should, pages were still visible in the menu, but the user cannot reach, gets redirected to the home page instead.

Hope this helps.

Apr 16, 2010 at 7:14 PM

Hi lockh,

I of course read your threads but was - and still am - a bit reluctant to go back to the standard sitemap provider. Mainly because I do not (yet) see the consequences. I guess I would also have to change Global.asax and classdiagram2.cd! Well I might try if I have time!

Being a bit naive I still hope that one of the creators speaks out!? I think they otherwise have done a good job!

anyway thanks for your time
ed

 

Apr 16, 2010 at 10:03 PM

It is very easy to switch to the standard xml sitemap provider, just change the web.config and everything "just works".

EXCEPT, I have to add, I removed the page administration/users.aspx by commenting it out in the app_data/web.sitemap,

and added some pages of my own which I already had, based on articles by Scott Guthrie and Scott Mitchell. You are probably already familiar with them.

Scott Guthrie  How to add a Login, Roles and Profile system to an ASP.NET 2.0 app in only 24 lines of code

Scott Mitchell - http://www.asp.net/learn/security/

 

Good luck with it.

Apr 17, 2010 at 7:00 AM
Edited Apr 17, 2010 at 9:11 AM

thanks again. will try once with the standard provider and go fro there!?

well, just tried and get an error in Global asax line 26 "HTTP exception; Request is not available in this context"
... this needs some more timeon my side I guess ...

Update - I couldn't resist:
I checked the 'enum MyWebPagesStarterKit.RoleNames'; when using 'RoleNames.? I get the choice of only Administrators, PowerUsers and Users BUT NOT the 'Roles' I defined in ASPNETDB.mdf!?!?
... where/how would I 'activate' these? And then I guess I still had to deal with in in the CustomSiteMapHandler .... well somewhen I might have time ....

.. but still hope that one of the creator guru's speak up!

ed

Apr 17, 2010 at 10:41 AM
Edited Apr 17, 2010 at 10:47 AM

I have not had that problem, and that line is about error logging - I wonder what error it was trying to log?

Actually, I had not changed global.asax until now, but I just had a look at it and noticed a reference to CustomXmlSitemapProvider, which I thought was rather naughty, and against the swappable provider idea?

The Bill Evjens documentation says it is easy to change to sql providers, just change the web.config; so I didn't expect to find hardcoded references like that.

Anyway, in a spirit of curiousity, I commented out that reference:

           // SiteMap.Provider.SiteMapResolve += new SiteMapResolveEventHandler(MyWebPagesStarterKit.Providers.CustomXmlSitemapProvider.Resolve);

and EXCLUDEd all three custom provider source files, and did a build. I got one error, about an unknown namespace in Administration\Navigation.aspx, which I also commented out:

//using MyWebPagesStarterKit.Providers;  commented out after EXCLUDEing the custom sitemap provider LH 17/04/2010

 

Then I rebuilt it, and it seems to be working fine (at least for a ten minute test)

The admin functions work and create and change pages and navigation and update the sitemap, roles seem to work fine, menu only shows me pages that I have the right roles for,

But still have the problem that the menus show non-"visible" pages but then you can't navigate to them unless you are an administrator (which is not how the documentation describes that feature).

 

As I said in an earlier post, I already changed the web.config to use sql membership and roles providers, as I was adding some database EasyControls and standalone pages.

Apr 17, 2010 at 3:37 PM

hi lockh, i really appreciate your time! It seems that we are the only ones who care or realized this issue ?
But this is pretty important to my WEB page!

I have not given up but I do not know when I have time to dig deeper! But I will ... somewhen!

I will, somewhen, document my findings! Hope so will you!

best reagrds and ahve a good weekend!

ed

 

Apr 23, 2010 at 2:21 PM
Edited Apr 23, 2010 at 11:16 PM
Hi guys! I'm newbie in MWPSK, but also want to learn it. It seems nice cms... At current moment I'm faced with hiding pages from menu... And as i understand there no solution yet? I'm right? The possible way is edit sitemap? is it correct? I just need to redirect user on some page1.aspx or page2.aspx , and don't want see this pages in menu... Please, give me some advice... Thanks in advance...
Apr 27, 2010 at 8:30 PM
some probably old but maybe usefull info from http://www.burstmode.de <quote> Rickard Magnusson and TBPrince developed a neat extension for "My Web Pages Starter Kit" (MWPSK) CMS. It allows for hiding pages from the navigation menu while it is still possible to set a direct link to those pages. Since I´ll need that feature for our new company website too, I decided to add it to MWPSKex which led to it´s current release MWPSKex.#003. Take a look at the dowload page at www.burstmode.de. You will find a complete solution there. These files had to be modified: ~/App_Code/WebPage.cs ~/App_Code/SitemapEditor.cs ~/App_Code/Providers/CustomSitemapDataSource.cs ~/Administration/Navigation.aspx ~/Administration/Navigation.aspx.cs Additionally in the default resource file "~/App_GlobalResources/StringsRes.resx" a new key "MWPSKex_adm_Navigation_VisibleInMenu" with a value of "Visible in menu" had to be added. Finally in (all) of the skin files in folder "~/App_Themes/": add this directive: Register TagPrefix="cc3" Namespace="MyWebPagesStarterKit.Providers" and replace the default sitemap datasource with our custom one: cc3:CustomSiteMapDataSource runat="server" ID="menuDataSource" ShowStartingNode="false" Hope this will be useful to anybody... </quote>
Apr 27, 2010 at 11:29 PM
Edited Apr 28, 2010 at 9:41 AM
http://www.burstmode.de/Default.aspx?pg=deb53614-d1d9-49fd-8cfc-228f362a0938&detail=a8489330-81ff-43ea-ba64-e0163aa96319#fc7fe166-dfe5-4adf-95c8-9e4da47e4d2d works fine for 1.3.0 version. I've checked!
Apr 28, 2010 at 7:01 AM

hi hunterex, you are right; burstmode did a good job on raising the functionality for MWPSK - I even have some WEB sites using it! BUT:

all those changes are based on back-level MWPSK i.e. the latest release officially supported was 1.2 . So far there is no update for 1.3.

I think you probably get on dangereous territory when using only certain 'code' from burstmode.

By the way, the reason I want to use 1.3 is the 'user registration business'. Now I relize, that 1.3 did obviously not implement it fully i.e.: the 'security question' is not handled which is a must when using the ASPNET.mdb. So there are some dependencies in this area: ASPNET.mdb, menu flexibility, roles and registration.

I will certainly listen to these relevant forums and tackle some of these issues when time allows !

ed

Apr 28, 2010 at 8:06 AM

I have posted "Visible checkbox does not work as documented" in the Issue Tracker section.

Maybe a few votes would help to get it fixed?

 

Apr 28, 2010 at 11:31 AM
edkaufmann, I'll be nice if you keep informed us about your investigation. Regarding "dangereous territory": as i see MWPSK team don't pamper us with new releases, so we have to add new features by myself... ockh, "Visible checkbox" i think only allow to hide page from menu... it usefull when you e.g. don't finish page and temporary need to hide it... IMHO...
Apr 28, 2010 at 4:24 PM
hunterex wrote:
"Visible checkbox" i think only allow to hide page from menu     ... it usefull when you e.g. don't finish page and temporary need to hide it... IMHO..."

But

(a) it doesn't hide the page from the menu - that's the issue I am raising.

(b) it is for more than just hiding a page so that the page cannot be used. It is for hiding a page from the menu so that the user can't go there directly, but can only get there from a link on another page.That is what the documentation said it was intended for.

The example I gave was a search page, where you select an item from a list or database, and then get sent to the hidden page with the ID  of the record you want to update, select from the previous page. You don't want the user to go to the detail page without the record key, or whatever, that he can select on the master page.

So I say there are two things wrong with the way it works in 1.3:

- it should hide the page from the menu, but currently it doesn't do that.

- it should let the user get to that hidden page by another route, but currently it doesn't do that.

 

Apr 29, 2010 at 6:51 AM

... you both are right and your impationce understandable BUT be aware it's a starter kit and, my impression, done to show the technology on how to build a WEB site!
Furthermore, there has never be a guarantee to fix issues nor develope it further. In fact I think it's done on a voluntary base ..
ed

Apr 29, 2010 at 7:35 AM

I do realise that, although it was developed for Microsoft,  there is no guarantee of enhancements, and some people have done much work on a voluntary basis.

I don't think I am being impatient, and I am working on workarounds and solutions of my own, as far as possible without breaking anything in the core system. But my fixes might be incompatible with some feature that I don't use, and I might never know about it because I will only test what I need.

But I think it makes sense to report anything that seems to be a bug - i.e., it doesn't do what the documentation says - and vote for the issues we would like fixed, so that they have a better chance of being fixed in a future version.

An update that gets included in the released version will benefit many more people than several individual, and probably incompatible, fixes.

So I suggest that if we find anything that looks like a bug, it should be posted, and voted for, in the issue tracker section.

Jun 7, 2010 at 10:49 PM

If you are still interested in this problem, see thread http://mywebpagesstarterkit.codeplex.com/Thread/View.aspx?ThreadId=209043

 

Jul 12, 2011 at 2:08 PM
Hi 
Apparently the Error remains same if you're working locally. Once the kit is uploaded the error re-surfaces. I'm getting this error:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load type 'MyWebPagesStarterKit.Providers.CustomXmlSitemapProvider'.

Source Error:

Line 35: 			<providers>
Line 36: 				<clear/>
Line 37: 				<add name="CustomXmlSitemapProvider" type="MyWebPagesStarterKit.Providers.CustomXmlSitemapProvider" securityTrimmingEnabled="true" siteMapFile="~/App_Data/Web.sitemap"/>
Line 38: 			</providers>
Line 39: 		</siteMap>

Source File: C:\inetpub\vhosts\kamalgroup.co.in\httpdocs\web.config    Line: 37

I read your post and tried to work out but somehow, something is still missing.
Thanks for your post
Jayant
lockh wrote:

I had problems too, and I think there are bugs in this part of MWPSK.

See my posts http://mywebpagesstarterkit.codeplex.com/Thread/View.aspx?ThreadId=209043

http://mywebpagesstarterkit.codeplex.com/Thread/View.aspx?ThreadId=209047

I found it worked better after I switched from the custom xml sitemap provider to the standard xml sitemap provider in web.config

    <!-- standard (non MWPSK) sitemap provider -->
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
      <providers>
        <clear/>
        <add name="XmlSiteMapProvider" description="Default SiteMap provider." type="System.Web.XmlSiteMapProvider" siteMapFile="~/App_Data/web.sitemap" securityTrimmingEnabled="true"/>
      </providers>
    </siteMap>

I also use Sqlmembership and roles providers.

I put roles in the app_data/web.sitemap like this ...

    <siteMapNode title="Database Maint" url="~/db.aspx" visible="True" pageId="4a4f9f1c-eaf4-45c5-a808-615e853ea130" roles="dbmaint, Administrators">
      <siteMapNode title="EventTypes" url="~/db/eventtypesmaint.aspx" visible="True" pageId="1a78eb3f-9c24-4169-a2bb-ebdbad9090d4" />
      <siteMapNode title="Events Maintenance" url="~/db/eventsmaint.aspx" visible="True" pageId="17b229a3-405f-4499-9604-d35b56b04c04" />

...

   </siteMapNode>

Do not allow anonymous access for the pages you want to hide.

I found that switching off "visible" did not work as I thought it should, pages were still visible in the menu, but the user cannot reach, gets redirected to the home page instead.

Hope this helps.