Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution 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 March 4th, 2004, 08:33 AM
Registered User
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default maintaining context

This has been touched on earlier but no solutions have worked with my problem. My web app context is reverting back to generic principle whenever I change pages. Therefore the site principle is having to intialize everytime a page loads which sort of defeats the purpose of it.

My web config file is set to forms authentication. I can see no reason why it should loose its context everytime.

cheers Joe

 
Old March 5th, 2004, 03:06 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same exact problem. But what is strange is that it used to work before. It doesn't after I reinstalled my system. Can it be because of the version 1.1?

Anyway, I researched the web and it looks like the solving might be that instead of using Context.User = newPrincipal, you can use:

Thread.CurrentPrincipal = newPrincipal

I didn't try this, but I will when I get home...

Please let me know if you find any other solution too...

Iulian


 
Old March 8th, 2004, 06:12 AM
Registered User
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

I have tried using the thread.currentPrinciple but still am having no luck. it is still reverting back to the generic principle every time a page loads. DId you have any luck in sorting the problem out ??

joe

 
Old March 8th, 2004, 01:25 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The only way I found is this:
instead of doing Context.User = myPrincipal, I do this:

Context["userid" + myPrincipal.Username] = myPrincipal;

Basically I cache the principal using the username as key. Then, in Global.asax in the OnRequestAuthenticate I do:

if (Request.IsAuthenticated)
{
 if (Context["userid" + Context.User.Identity.Name] != null)

or something like that. Basically, in the global.asax I restore the principal from the cached object and there you can set the principal and you won't loose it.

I also make sure I remove the key from the cache on Session end and everytime the user logs out...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to set context in web.xml or context.xml. dchicks Apache Tomcat 1 March 7th, 2008 07:59 AM
Maintaining state in a TreeView Nick710 ASP.NET 2.0 Professional 3 December 23rd, 2005 01:58 PM
Maintaining Context.User cjh301 BOOK: ASP.NET Website Programming Problem-Design-Solution 6 March 30th, 2004 04:50 AM





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