Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2006, 07:28 PM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default Processing all pages, app or session wide

I'm kinda stuck on finding the best place to accomplish the following:

1. App website contains approx 60 aspx pages. At the start of a *SESSION*, I need to
partially enable a menu on all 60 pages that is inherited from the master page, where
the menu is inherited disabled. Session of course is for one user only. There are simultaneous sessions with other users going on. Each user in each session will have a different set of enabled /disabled menu selections depending upon his/her login role.

2. I can't find the object (application? session?, ?) where all the pages live and can
be dealt with (portions of menu enabled or disabled) from the Session Start code in Global.asax.

3. What's got me worried is that if I find the place where all the pages live and enable and disable individual pages as required for some particular user, some other user will see the same pages -- which will be inappropriatedly enabled or disabled as far as he is concerned.

4. But first things first, where do all the pages live?

5. When I change a page in a session, is it a copy of a page that gets changed or is
the one and only page itself?

6. Help anyone.

VictorVictor



 
Old July 21st, 2006, 11:11 AM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hmm...

If I understand your problem correctly you are trying to disable access to some pages according to the current users credentials. To solve this problem, you need to cache the state of the menu in the Page.Session object. On loading the menu, you can quickly and easily reference this same Session variable.

So, if the Session["MenuSetup"] (or whatever you call it) is null, then you know that you need to parse the current users access to the menu items. If is has a value, just pass it to your SetMenuItemsVisibility function.

The way I see it, it isn't necessary to use the Global.asax.cs file at all. Set up a static function on a seperate class, so it can be used in multiple places through your app.

hope this helps and isn't too confusing



www.CoderForRent.com
Get A Computer Job!

www.ComputersComplete.com
Computer Parts & Accessories
 
Old July 22nd, 2006, 04:45 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Coder4Rent: Thanks for the reply and the thought that went into it.

This problem relates to the previous one I wrote a day before. Imar Spanjaar came up with a good idea and you've got one too.

However, Microsoft has actually solved this problem which I only discovered after much reading in the help files. I should have read first and complained second.

The basic problem, which many website designers are going to encounter is that in a project employing: master page MENU visual inheritance, roles for users, and selected access to pages depending upon roles, there needs to be some easy, non code solution.

Microsoft has provided that simple required functionality by the addition of a few lines in the web.config file. That is, one simply includes a block as follows:

        <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
            <providers>
                <add name="XmlSiteMapProvider"
                    description="Default SiteMap provider."
                    type="System.Web.XmlSiteMapProvider "
                    siteMapFile="Web.sitemap"
                    securityTrimmingEnabled="true"/>
            </providers>
        </siteMap>

The key item above is the attribute: securityTrimmingEnabled="true". That's all there is to it.

I don't have to mess with the session or app object. It's all automatic as far as I'm concerned. I have tested my app with 3 simultaneous users banging on it, each with different user names and roles. App correctly displays the desired menu options depending upon the roles and user names which are all different from one another.

VV



 
Old July 22nd, 2006, 05:19 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My reply above contains an incomplete sentence:

The basic problem, which many website designers are going to encounter is that in a project employing: master page MENU visual inheritance, roles for users, and selected access to pages depending upon roles, there needs to be some easy, non code solution.

It should read:
The basic problem, which many website designers are going to encounter is that in a project employing: master page MENU visual inheritance, roles for users, and selected access to pages depending upon roles, there needs to be some easy way for customizing and presenting the menu so that it displays the appropriate options for each user in each role, and without having to write custom code.

VV







Similar Threads
Thread Thread Starter Forum Replies Last Post
Persistent Session State accross multiple pages Admiral1701 Internet Information Services 0 December 13th, 2006 06:27 PM
App wide code - where to put it? VictorVictor ASP.NET 2.0 Basics 5 May 31st, 2006 02:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.