473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Menu items keep disappearing

Hi all

In my login form (forms authentication) I check that the login is valid,
retrieve an "Author" object, and keep track of the author's roles.

string[] roles;
if (author.IsAdministrator)
roles = new string[] {"Admin", "Member"};
else
roles = new string[] {"Member"};
Cache.Add(author.UniqueId, roles, null, DateTime.MaxValue,
TimeSpan.FromHours(1), CacheItemPriority.BelowNormal, null);
In my Global.asax.cs file I execute the following code in order to ensure
that the author's roles are available to forms authentication...

protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.User != null)
{
IIdentity userId = HttpContext.Current.User.Identity;
//Do we have some roles to retrieve? If so, replace the user object
if (HttpContext.Current.Cache[userId.Name] != null)
{
string[] roles = (string[]) HttpContext.Current.Cache[userId.Name];
HttpContext.Current.User =
new System.Security.Principal.GenericPrincipal(userId, roles);
}
}//user != null
}
The problem I have is that the host site seems to keep changing its mind as
to whether or not my login has the "Admin" role or not.

<location path="Admin">
<system.web>
<authorization>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>

Whenever I am navigating my way around within the /Admin folder, I will
(apparently randomly) be redirected to the Login page as if I were not an
Admin, or not authenticated. However, refreshing the /Admin/whatever.aspx
url repeatedly will eventually allow me to continue.

This fact is reflected in my menu control. I have an "Administration"
section which is displayed/hidden depending on

HttpContext.Current.User.IsInRole("Admin");

Repeatedly refreshing any page at all, including a page with no
restrictions, will (apparently randomly) show/hide the Administrator menu
items.

Can anyone shed some light onto this behaviour? The last point made seems
to indicate that the user identity is being lost somehow.

Thanks
--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
Nov 19 '05 #1
1 2252
Just thought I'd mention the solution.

It would seem that the Cache[] was not consistent between requests because
of the pooling type set within IIS. Setting it back to "pooled" seems to
have done the trick.
--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com

My blog
http://blogs.slcdug.org/petermorris/
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
1
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i...
0
by: bubbagump | last post by:
Hey hey.... Need some help with CSS menus. I need to figure out how to keep my main menu items highlighted when I am hovering on sub-items or sub-sub-items. Here is my code: #menu { width:...
0
by: kinane3 | last post by:
Mostly I need to figure if I'm wasting my time or if there is a way to do what I am trying to do. I am an intermediate to CSS at best so please don't flame me, just trying to do my job here. I...
2
by: Greg | last post by:
I wonder if someone would help me and take a look at a strange problem I'm facing with a webpage I'm building. The page is at http://author.www.purdue.edu/swo/test.html. By using Internet...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: Kayvine | last post by:
Hi guys, this is a question I have for an assignment, it is pretty long, but I am not asking for the code(well if someone wants to write I'll be really happy, lol), but I just want to know how to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.